A simple timer to time blocks of code.
Returns an array containing the total time taken for all iterations (micros_total) and average time taken per iteration (micros_average).
timer(1) => { }
Time a single iteration.
Code
timer(1) => { sleep(5) }
Result
array((micros = 5184.000000), (micros_average = 5184.000000))
Code
var('timeTaken') = timer(1) => {
loop(1000000) => {
}
}
'That section of code took ' + $timeTaken->first->second * .000001 + ' seconds.';
Result
That section of code took 0.489982 seconds.
Time multiple iterations.
Code
timer(1000) => { sleep(5) }
Result
array((micros = 5276669.000000), (micros_average = 5276.669000))
When testing small chunks of code the more iterations you use the more acturate the average will be. 10,000+ is good for tiny portions of code.
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments