Even for short list (15 elem) of random time segments of DateObjects, Accumulate
consumes unexpectedly long times. But, when time segments are not random, or are Accumulated as a Quantity
, prior adding to DateObject (conversion to DateObject), there are no such long computation long times. For list of length few dozens computation time approaches infinity. Eg.
Delta times before accumulation:
dtimqr = Quantity[IntegerPart[RandomVariate[GammaDistribution[9, 0.1], 15]*86400], "Seconds"];
dtimq = Quantity[Table[135000, 15], "Seconds"];
Accumulation as a DateObjects:
{Timing[ftimr = Accumulate@({FromUnixTime[0]}~Join~dtimqr);],
Timing[ftim = Accumulate@({FromUnixTime[0]}~Join~dtimq);]}
(* {{14.0625, Null}, {0.0625, Null}} *)
{Timing[ftimrP=FromUnixTime[0]+Accumulate@({Quantity[0, "Seconds"]}~Join~dtimqr);],
Timing[ftimP=FromUnixTime[0]+Accumulate@({Quantity[0, "Seconds"]}~Join~dtimq);]}
(* {{0.0625, Null}, {0.046875, Null}} *)
Is there reasonable explanation for such a long computation time when Accumulating lists with random dateObjects, as short as 15 elements. ?
DateObject[]
s. I would suggest keeping things inUnixTime[]
orAbsoluteTime[]
, and convert to explicit dates only when you need to display them. $\endgroup$