1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
alias testloops { var %time = $ticks, %k = 0 while (%k <= 1000000) { inc %k } var %while.inc $calc(($ticks - %time)/1000) echo -a A) inc completed in %while.inc secs var %time = $ticks, %k = 1000000 while (%k >= 0) { dec %k } var %while.dec $calc(($ticks - %time)/1000) echo -a B) dec completed in $calc(($ticks - %time)/1000) secs echo -a C) The fastest loop: $iif(%while.dec > %while.inc,dec loops,inc loops) - Difference: $abs($calc(%while.inc - %while.dec)) secs } |
echo -a A) inc completed in %while.inc secsecho -a B) dec completed in $calc(($ticks - %time)/1000) secsecho -a C) The fastest loop: $iif(%while.dec > %while.inc,dec loops,inc loops) - Difference: $abs($calc(%while.inc - %while.dec)) secs| Parsed for bracket errors and indented: | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
alias testloops { var %time = $ticks, %k = 0 while (%k <= 1000000) { inc %k } var %while.inc $calc(($ticks - %time)/1000) echo -a A) inc completed in %while.inc secs var %time = $ticks, %k = 1000000 while (%k >= 0) { dec %k } var %while.dec $calc(($ticks - %time)/1000) echo -a B) dec completed in $calc(($ticks - %time)/1000) secs echo -a C) The fastest loop: $iif(%while.dec > %while.inc,dec loops,inc loops) - Difference: $abs($calc(%while.inc - %while.dec)) secs } |