Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid toc() printing the time elapsed in Julia?

Tags:

julia

This might be a really stupid question, but I'll go ahead anyway. I'm trying to use Julia's tic() and toc() inside a loop in order to figure out some timing issues. A dummy example is shown below:

elapsedTime = zeros(3);

for i = 1:3
    tic();
    pause(i)
    ElapsedTime[i] = toc();
end 

The goal is to store the elapsed time intervals in the array ElapsedTime. The issue is that toc() seems to a) print the elapsed time to screen and b) store it as wanted.

Is there some simple trick to avoid a), ie. that toc() prints the result? It's not a huge problem, just annoying if the number of iterations is large.

Any help will be greatly appreciated!

like image 466
Kjetil Sonerud Avatar asked May 26 '14 14:05

Kjetil Sonerud


1 Answers

there is another version of toc() called toq() which doesn't print a thing and returns the elapsed time.

like image 101
Dan Getz Avatar answered Oct 01 '22 01:10

Dan Getz