Notifications
Clear all

[Closed] The timer is mysterious

I would like to determine the time elapsed when a function is running (I want to compare speed performance)
I have tried this, but that’s not working.
The timer works only when the computer makes nothing!

Can anybody help me? I don’t understand…
Thanks

utility testSpeed "test speed"
(
	timer clock "timer" interval:100
	button test_osd "test 1"
	button test2_osd "test 2"

	fn myfunction =
		(
		clearListener()
		startTimer=clock.ticks
			-- Time to measure
			messageBox("timer is running .... press me to stop")
		messageBox ("timer="+((clock.ticks-startTimer)/10.0) as string+" sec")
		)--fn

	fn myfunction2 =
		(
		clearListener()
		startTimer=clock.ticks
			-- Time to measure
			for i=1 to 2000000 do (j=sqrt i)
		messageBox ("timer="+((clock.ticks-startTimer)/10.0) as string+" sec")
		)--fn

	on test_osd pressed do myfunction()
	on test2_osd pressed do myfunction2()
)
createDialog testSpeed
2 Replies
 PEN

Right from the help file, is this what you want?

 start = timeStamp() 
process_mesh() -- do some big job
end = timeStamp()
format "Processing took % seconds
" ((end - start) / 1000.0)

1 Reply
(@prettypixel)
Joined: 2 years ago

Posts: 0

thanks you very much PEN, it’s exactly what I wished!
the function timestamp() work in all cases
I did not think of using the hour of the system :argh:

your help is precious, thanks you again