Program Cycles in Hertz by Galiem Vaelant29th Dec 2004 13:59
|
---|
Summary This short bit of code will calculate and return the number of cycles per second your program runs at in hertz, the SI unit for cycles per second. Description This short bit of code will calculate and return the number of cycles per second your program runs at in hertz, the SI unit for cycles per second. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Ensure that the below is processed before your program enters its main loop DIM loops(1) : loops(0) = 0 DIM start_time(1) : start_time(0) = TIMER() DIM hertz(1) : hertz(0) = 0 `Below is your main loop DO INC loops(0) IF TIMER() - start_time(0) >= 1000 time_thus_far = TIMER() - start_time(0) hertz(0) = loops(0)/(time_thus_far/1000) ENDIF Hertz$ = "PC@"+STR$(hertz(0))+"Hz" LOOP `Hertz$ is valid after 1 second real time. This is needed to prevent a division by zero. |