Quote: " Windows operating systems are extremely busy places with alot going on the user doesn't see"
True, but I'm not exactly sure how that effects the speed of the test if the RAM is sufficient to have excess RAM left over for the program and System Idle Process is 99% CPU usage.
Quote: "In theory, but we're not the only thing running on the system. Time is being eaten not purely by our program, but other applications in the background."
I guess I could switch it to something other than sync... maybe just add an integer, but I might need to make a bunch more loops to see if theirs a time difference.
EDIT: Actually, I just changed it to perform no calculations/commands that don't relate to the loop.
Results after 1 million loops taken once:
Baseline(taken after program loaded and got to first wait key):
CPU Usage: 27%
Mem Usage: 23%
Peak usages(during program):
CPU Usage: 29% (No more than 75% on one core)
Mem Usage: 23%
Do/Loop = 77315 ms
Goto = 78209 ms
While/EndWhile = 78227 ms
Repeat/Until = 78411 ms
For/Next = 2 ms
Source code:
// Do... Loop
loopcount = 0
ElapsedTime = hitimer()
do
inc loopcount
if loopcount = 1000000 then exit
loop
ElapsedTime = hitimer() - ElapsedTime
Print "Time for Do... Loop to do 1000000 loops = " + str$(ElapsedTime)
Print "Press any key to continue."
Wait key
CLS
// Goto...
loopcount = 0
ElapsedTime = hitimer()
GotoMe:
inc loopcount
if loopcount = 1000000 then Goto ExitMe
Goto GotoMe
ExitMe:
ElapsedTime = hitimer() - ElapsedTime
Print "Time for GoTo... to do 1000000 loops = " + str$(ElapsedTime)
Print "Press any key to continue."
Wait key
CLS
//While... EndWhile
loopcount = 0
ElapsedTime = hitimer()
While loopcount < 1000000
inc loopcount
EndWhile
ElapsedTime = hitimer() - ElapsedTime
Print "Time for While... EndWhile to do 1000000 loops = " + str$(ElapsedTime)
Print "Press any key to continue."
Wait key
CLS
//Repeat... Until
loopcount = 0
ElapsedTime = hitimer()
Repeat
inc loopcount
Until loopcount = 1000000
ElapsedTime = hitimer() - ElapsedTime
Print "Time for Repeat... Until to do 1000000 loops = " + str$(ElapsedTime)
Print "Press any key to continue."
Wait key
CLS
//For... Next
loopcount = 0
ElapsedTime = hitimer()
For loopcount = 1 to 1000000
Next loopcount
ElapsedTime = hitimer() - ElapsedTime
Print "Time for For... Next to do 1000000 loops = " + str$(ElapsedTime)
Print "Press any key to continue."
Wait key
End
If at first you dont succeed, LOWER YOUR STANDARDS.