here a little timer i use frequently. you dont have to put code in between the start and end time but it will tend to be more reliable.
I generally build the majority of my programs inside a timer so i can throttle memory usage on things that dont need to be running but yet have to. hope it helps
StartTime=timer()
if inctime >10
`code here that u want to run time based
endif
`reset timer to zero
if inctime> 100
inctime=0
endif
EndTime=timer()
ElapsedTime=EndTime-StartTime
inctime=inctime+elapsedtime
A child's dream never dies.