-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
performanceMust go fasterMust go fasterpotential benchmarkCould make a good benchmark in BaseBenchmarksCould make a good benchmark in BaseBenchmarks
Description
This seems odd to me:
julia> f(X) = [sin(x) + x^2 - 3 for x in X]
x = linspace(0,1,10^7)
@time f(x);
0.286351 seconds (6 allocations: 76.294 MB, 0.21% gc time)
julia> x = collect(x)
@time f(x);
0.085037 seconds (6 allocations: 76.294 MB, 5.49% gc time)
I can understand why e.g. x.^2 might be slower for a linspace, since the computation is so cheap compared to computing the elements of the linspace on the fly, but I don't understand why a more complex operation like this, in a comprehension where the elements are calculated only once per computation, is so much slower.
See also the mailing list discussion.
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go fasterpotential benchmarkCould make a good benchmark in BaseBenchmarksCould make a good benchmark in BaseBenchmarks