timer

 BBS: Inland Empire Archive
Date: 04-04-92 (11:42)             Number: 141
From: RICHARD VANNOY               Refer#: NONE
  To: JADE APISUKH                  Recvd: NO  
Subj: timer                          Conf: (2) Quik_Bas
JA>Hi guys, I'm looking for some really small code so I can time the
JA>execution of one of my programs.  I know I could do a TIME$ - TIME$ type
JA>thing, but if it overlaps at the minute or such, problems could arise.
JA>Is there anyway to time on of my programs very accurately, like down to
JA>the millisecond, or at least the second?

starting& = TIMER
'Put your code here
ending& = TIMER
PRINT "Time:"; ending& - starting&

TIMER returns the number of seconds since midnight, so this
would be good to one second.
If you have something that takes just milliseconds, do it
several hundred times, then divide the time by the number
of loops.

starting& = TIMER
FOR i = 1 to 1000
   x = rnd
NEXT i
ending& = TIMER
PRINT "Time:"; ending& - starting&
then just divide by 1000.

> MegaMail 2.1b #0:Bugs are sons of glitches!


--- WM v2.01/91-0012
 * Origin: Com-Dat BBS  Hillsboro, OR.  HST (503) 681-0543 (1:105/314)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET