Hello,
I am working on an app which will be doing analysis on a lot of
numerical data. Julia seems perfect for the job. However I wanted to do
a simple test that I have run on a few languages to see where I wanted
to land.
Yes, I understand benchmarks, micro-benchmarks are evil. But I needed to
see a little on how the languages performed in cpu, time and memory.
Basically I have two almost identical test differing only in how large
the array is that I am operating over. One is 100million items, the
other 7.2million items. The reason for the two test is I am expecting at
the start the 7.2m to be more normative, but I want to test towards some
upper bounds. Some languages I can't do the 100m because the reach
memory constraints.
The array is simply populated with doubles or Float64 in Julia's case.
In the test I iterate over the array, do some calculations assign back
into the array. The calculations are simple calculations which can be
reasonably consistent across languages. I do this iteration over the
array 100 times.
Hardware, Laptop, 3rd Gen, i7, 12GB Ram
Lubuntu 14.10, running Openbox only, not Lubuntu DE
Julia -- Version 0.3.1-pre+4720
a = Array(Float64, 7200000)
# populate array with some data
for i = 1:length(a)
n = i * 0.99999
if n>100
n-=(n-n/100.0)
end
a[i]= n*n*n
end
println("$(a[1]), $(a[end])")
for i = 1:100
t=time()
for j = 1:length(a)
n = a[j] * 0.99999 + (a[j]+1.0) / 0.9999999
n*=0.99999
n*=0.99999
n*=0.99999
n/=0.9999999
n/=0.9999999
n/=0.9999999
if n>100
n-=(n-n/100.0)
end
a[j]= n
end
println("loop number $i $(a[1]), $(a[end]), $(time()-t)")
end
With an array of 7.2m the test times are:
C++11 gcc4.9 18.5 seconds, 58.6mb ram
Java openjdk7 18.8 seconds, 77.5mb ram
Julia 0.3.1 675 seconds, 156mb ram
Luajit 5.1 22.3 seconds, 67mb ram
I didn't necessarily expect Julia to match or beat C++. But I did hope
it would be more comparable.
Am I doing something wrong? Is my code not good Julia or idiomatic
Julia. Or is this simply where Julia is at this point in time?
Any help, understanding or wisdom greatly appreciated.
Thanks.
Jimmie