$avgNum:10 #The average, min, and max will be over this many invocations. $showMin:1 $showAvg:1 $showMax:1 $checkStack:1 $iterations:1000 #How many times to execute the code every invocation. ElapsedTime ->start <-iterations 0 do #CODE TO MEASURE GOES HERE loop @EndMeasure #=============== :Once <-avgNum CreateListStartingSize ->timeList :EndMeasure ElapsedTime <-start sub ->timeTaken if(StackSize <-checkStack &&) Trace(StackSize <-iterations div " items left on the stack!" concat) endif ClearStack <-timeTaken ->timeList[InvocationCount <-avgNum mod] 9999999 ->min 0 ->max 0 InvocationCount 1 add <-avgNum min 0 do #Find the average <-timeList[i] dup <-min min ->min dup <-max max ->max add loop <-avgNum InvocationCount min div ->avg <-timeTaken @Pad if(<-showMin) "min: " <-min @Pad endif if(<-showAvg) "avg: " <-avg 1 round @Pad endif if(<-showMax) "max: " <-max @Pad endif TraceAll #Gets close, but non-monospace fonts (like the tracelog) aren't exact. #Doesn't use a tab because sometimes that makes the issue worse. :Pad dup StringLength 8 swap sub 0 do " " loop