Issue introduced in version 10, fixed in 10.0.2
Compilation nowadays may give very fast functions. Here is an example for finding the sum of a list of machine numbers, just as the built-in function Total
:
myTotal = Compile[{{lst, _Real, 1}},
Module[{s = 0.}, Do[s = s + x, {x, lst}]; s],
CompilationTarget -> "C"];
lst = RandomReal[{0, 1}, {10^7}];
myTotal[lst] == Total[lst]
(*True *)
In Mathematica 10, I noted the surprising fact that the function myTotal is more than three times as fast as Total
:
Do[myTotal[lst], {500}] // Timing (* {4.758031, Null} *)
Do[Total[lst], {500}] // Timing (* {16.052503, Null} *)
In Mathematica 9, they are as fast. So in Mathematica 10 (on Windows), Total is more than 3 times slower than in Mathematica 9, fortunately of course still very fast. What could be the reason for this slowdown?
Comments
Post a Comment