Many scientific computing languages distinguish between absolute time (wall clocks) and processor time (processor cycles). For example, in Matlab we have:
>> tic; pause(1); toc Elapsed time is 1.009068 seconds. >> start = cputime; pause(1); elapsed = cputime - start elapsed = 0
and in Mathematica we have:
>>In[1]:= AbsoluteTiming[Pause[1]] >>Out[1]= {1.0010572, Null} >>In[2]:= Timing[Pause[1]] >>Out[2]= {0., Null}
This difference is useful when the comparison code is executed on computing servers, where there may be high variance in the absolute synchronization results, depending on what other processes are running at the same time.
The Julia standard library supports expression synchronization using tic() , toc() , @time and several other functions / macros based on time_ns() , a function that measures absolute time.
>>julia> @time sleep(1) elapsed time: 1.017056895 seconds (135788 bytes allocated)
My question is: is there an easy way to get elapsed processor time to evaluate an expression in Julia?
(Lateral note: after doing some digging, it seems that Julia’s time is based on the uv_hrtime() function from libuv . It seems to me that using uv_getrusage from the same library can give access to the elapsed processor time in Julia, but I'm not an expert. Someone tried using something like that?)
performance time julia-lang
eds
source share