TIMER returns the number of seconds, one thousandth of a second resolution, since the current session of Windows started. This differs from other BASIC dialects which return the number of seconds since midnight.
Syntax:RetVal = TIMER Return Value:
Parameters:
|
DIM primes% DIM start! DIM finish! DIM duration! start! = TIMER primes% = count_primes(99999) finish! = TIMER duration! = finish! - start! PRINT "It took" & duration! & " seconds to calculate that" PRINT "there are", primes%, " primes lower than 100,000." FUNCTION count_primes (n%) DIM freq% freq = n - 1 XFOR INTEGER i = 2 WHILE i <= n BY ++i XFOR INTEGER j = SQRT(i) WHILE j > 1 BY --j IF i % j = 0 THEN --freq EXIT XFOR END IF XNEXT XNEXT FUNCTION = freq END FUNCTION
It took 0.07763672 seconds to calculate that there are 9592 primes lower than 100,000.
TIX_NOW returns a double precision count of milliseconds since TIX_START was called.
Syntax:TIX_START Code block being timed. MilliSeconds = TIX_NOW Return Value:Parameters:
|
These were inspired by the PowerBasic TIX implementation. Actual resolution (precision) can vary by hardware and operating environment. Timing values in microseconds and even nanoseconds have been reported when running under Windows 10/11 on some business class computers and workstations.
TIX_START and TIX_NOW rely on the Win32 API function QueryPerformanceCounter to produce TIX_NOW's high resolution result.
TIX_START ' Re-initializes two internal variables. DELAY 1 ' This could be any amount of code that you want to measure. PRINT TIX_NOW ' BCX knows that TIX_NOW is a double precision function. PAUSE