startmacro

set MAX_LOOP_TIME 1.0 ! Try to iterate for this length of time

info "Performing speed measurement..."
timer set
set D:nLoop 10000
do i 1 nLoop
  set x^i i
enddo
timer elapsed t
calc timePerSet t/nLoop
remove x*
info "^nloop SETs took ^t secs, ^timePerSet secs per SET"

calc L:MAX_SET_ITERATIONS MAX_LOOP_TIME timePerSet / ROUND
calc L:MAX_EMPTY_ITERATIONS MAX_SET_ITERATIONS 10 *
calc L:MAX_TABLE_SET_ITERATIONS MAX_SET_ITERATIONS 10 /

info "Your computer should perform about ^MAX_SET_ITERATIONS SETs in ^MAX_LOOP_TIME secs"

info "Performing empty loop..."
timer set
do i 1 MAX_EMPTY_ITERATIONS
enddo
timer elapsed t
calc timePerSet t/MAX_SET_ITERATIONS
info "Done. Time = ^t, TimePerIteration = ^timePerSet secs"


info "Performing RESULT SET test..."
timer set
do i 1 MAX_SET_ITERATIONS
  set x^i i
enddo
timer elapsed t
calc timePerSet t/MAX_SET_ITERATIONS
info "Done. Time = ^t, TimePerSet = ^timePerSet secs"


info "Performing TABLE RESULT SET test..."
set tab {}
timer set
do i 1 MAX_TABLE_SET_ITERATIONS
  set tab.^i i
enddo
timer elapsed t
calc timePerSet t/MAX_TABLE_SET_ITERATIONS
info "Done. Time = ^t, TimePerSet = ^timePerSet secs"


endmacro
