MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: why DateListPlot is so slow?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79934] Re: why DateListPlot is so slow?
  • From: "Rolf.Mertig at gmail.com" <Rolf.Mertig at gmail.com>
  • Date: Thu, 9 Aug 2007 05:17:25 -0400 (EDT)
  • References: <f9c0ae$5o4$1@smc.vnet.net>

Using good old ListPlot with Ticks I can get a speed increase of
factor 15:

d[h_] :=
   Table[Round[Drop[ToDate[i], 3]],
      {i, 0, h*3600, 30}] /. j_Integer :>
      If[j < 10, StringJoin["0", ToString[j]],
       ToString[j]] /. {a_String, b_, c_} :>
     {StringJoin[a, ":", b, ":", c], Random[]};
oldp[i_] := ListPlot[Last /@ d[i],
   Ticks -> {{{1, d[i][[1,1]]},
      {Floor[Length[d[i]]/2],
       d[i][[Floor[Length[d[i]]/2],1]]},
      {Length[d[i]], d[i][[-1,1]]}}, Automatic},
   PlotRangePadding -> 0];
   AbsoluteTiming[DateListPlot[d[12]]]
AbsoluteTiming[oldp[12]]

----------
I suspect the reason why DateListPlot is so slow (which basically
makes it useless for larger data sets) is
that it uses DateList and DateString internally which seem to use
JLink and Java and this just gets slow
if called a lot. I did send the example below to WRI some months ago
([WR #928602]) and I am sure
they are working hard on fixing this:

In[1]:= !!datelist
t[n_] := Table[DateString[DatePlus[i], {"Year", "-", "Month", "-",
"Day"}], {i, n}];
Print["$Version = ",$Version];
Print["DateString timing: ", Timing[t2000 = t[2000];]];
Print["DateList timing: ", Timing[tmp = DateList/@t2000;]];
Print["quick way : ", Timing[qui=Join[ToExpression@StringSplit[#,
"-"], {0, 0, 0.}] & /@ t2000;]];
Print["check ", qui===tmp];
Print["loaeded Java classes = ",LoadedJavaClasses[]];

In[1]:= <<datelist
$Version = 6.0 for Linux x86 (64-bit) (June 19, 2007)
DateString timing: {2.44015, Null}
DateList timing: {4.8683, Null}
quick way : {0.032002, Null}
check True
loaeded Java classes = {JavaClass[java.text.Format, <>],

>    JavaClass[java.text.DateFormat, <>], JavaClass[java.lang.Object, <>],

>    JavaClass[java.text.SimpleDateFormat, <>]}

------

Rolf Mertig
http://www.gluonvision.com
GluonVision GmbH
Berlin, Germany



  • Prev by Date: Re: framed plots with two y axes scales
  • Next by Date: Re: why DateListPlot is so slow?
  • Previous by thread: Re: why DateListPlot is so slow?
  • Next by thread: Re: why DateListPlot is so slow?