TicToc

Average rating
(0 votes)

Timing sections of code is relatively simple in IGOR, using startMStimer and stopMStimer, but the two following functions make it even more simple, much like it is in MATLAB.

function tic()
	variable/G tictoc = startMSTimer
end
 
function toc()
	NVAR/Z tictoc
	variable ttTime = stopMSTimer(tictoc)
	printf "%g seconds\r", (ttTime/1e6)
	killvariables/Z tictoc
end

Here is an example of the use of tic() and toc() functions to time some FFTs.

Function testTicToc()
 
	tic()
	variable i
	For(i=0;i<10000;i+=1)
		make/O/N=512 temp = gnoise(2)
		FFT temp
	Endfor
	killwaves/z temp
	toc()
End

Output to history is:

•testTicToc()
1.3182 seconds

P.S. I vastly prefer IGOR to MATLAB, I just wanted to make inserting a timer into code a bit easier.

Back to top