Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2 -------- 11/07/2008 @ 12:48 by aldweb
visitor |
The CPU has an internal clock which beats on a regular basis thanks to an integrated quartz. Each time it beats (or "ticks"), it will increment a counter. To convert this counter to our standard time measurement system (hours, minutes, seconds), we need to know how many quartz beats happen in one second.
Then: TICKS returns this quartz' beating counter TICKSPERSEC returns the number of beats per second
So, retrieve the counter once, do something, retrieve the counter a second time, calculate the number of beats that happened while doing this thing, divide by the number of beats per second, and you will know how long it took to do that thing. Got it?
Sample:
BEGIN T=TICKS 'retrieve initial tick FOR I=1 TO 100 'do something important... NEXT T=(TICKS-T)/TICKSPERSEC 'magic formula! PRINT T 'number of seconds required to do our important thing WAIT END
Cheers, aldweb
|