Measuring processor elapsed time in Julia

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?)

+8
performance time julia-lang
source share
2 answers

I could not find any existing solutions, so I put together a package with some simple processor synchronization functions here: https://github.com/schmrlng/CPUTime.jl , The package is completely untested on the parallel code and may have other errors, but if someone she’ll also want to try it, causing

 >> Pkg.clone("https://github.com/schmrlng/CPUTime.jl.git") 

from the julia> prompt should install the package.

+5
source share

Julia has tic() and toc() commands that work like tic and toc in Matlab:

 julia> tic(); 7^1000000000; toc() elapsed time: 0.046563597 seconds 0.046563597 
+9
source share

All Articles