This is yet another set of tags which allows you to set markers in your scripts and return the elapsed times between them. This version consists of two tags, [timer] and [timerstats], and works as follows:
You place markers in your code by calling [timer] with an optional note/label. You must set at least one "starter" timer before the first event you wish to time. If you want to see the results immediately, you may set the -collect param to false. Otherwise each duration is collected and displayed when [timerstats] is called.
Both tags require a page variable called 'debug' to be set to true, otherwise they immediately return null, so it's okay to leave your markers in place.
The [timerstats] tag returns a table showing each marker and the elapsed time both in milliseconds and as a percentage of the total (which is also shown). Percentages are represented as a CSS bar graph. The CSS is embedded within the tag for portability.
Parameters
none
Sample Usage
// start the timer
var('debug') = true;
timer('started timer');
// do some stuff
sleep(200);
// set a marker
timer('did some stuff');
// do more stuff
sleep(100);
// set another marker
timer('did some more stuff');
// display results
timerstats;
Source Code
Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
02/17/2008, Jason Huck Updated
Per request, [timerstats] now explicitly checks for $debug to be true rather than relying on whether or not [timer] has collected any data.
Updated
Per request, [timerstats] now explicitly checks for $debug to be true rather than relying on whether or not [timer] has collected any data.