Hello, I am new to julia. I just installed the latest julia 1.3.1, and then run several small timings.
First I define
Then timing the first time
0.073568 seconds (231.55 k allocations: 11.170 MiB)
this is unreasonably slow.
@time a+a the second time gives
0.000004 seconds (5 allocations: 272 bytes)
According to the “performance-tips” in the manual, it does mentioned that
On the first call (
@time sum_global()) the function gets compiled. (If you’ve not yet used
@timein this session, it will also compile functions needed for timing.)
But I don’t understand. Does something as simple as
a+a also need to go through a JIT compilation process for the first time? If so, how could Julia be fast because 0.07s is absurd for
[1,2,3]+[1,2,3], and I am not sure if the second timing result is just cached result or not.
I never encountered this kind of wierd timing in python. For example, using numpy
a=np.array([1,2,3]) %time a+a
CPU times: user 29 µs, sys: 3 µs, total: 32 µs Wall time: 38.1 µs
and purely python interpreter is even faster for this small scale problem.
a=[1,2,3] %time [i+i for i in a]
CPU times: user 8 µs, sys: 1 µs, total: 9 µs Wall time: 12.9 µs
So how to understand my
Julia timing result? How could Julia be fast?