Stores executiion times between begin() and end() functions
The Profiler class is for tracking execution time. More than one Profiler can be active at a time, but generally it is most convenient to use the global $profiler instance.
<%
$profiler.mark("Starting interesting section");
var num_loops=100,i=0;
$profiler.begin("Create " + num_loops +" encrypted passwords.");
for (; i < num_loops;++i){
$profiler.begin("Create encrypted password");
$lib.string.encryptPassword("NunyaBidness");
$profiler.end("Create encrypted password");
}
$profiler.end("Create " + num_loops +" encrypted passwords.");
$profiler.mark("All Done!");
$profiler.calcAverages();
%>
<%=$profiler.getSummaryHtml()%>
Displays HTML somewhat like this...
Label Elapsed Millis Elapsed Total Millis
$application import 10 758
Include file:/data/tomcat/webapps/myna/application.sjs 0 751
Runtime scripts included 760
Starting interesting section 763
Create 100 encrypted passwords. 237 1004
Create encrypted password (Avg of 100 entries) 2
All Done! 1004
| Myna. Profiler | Stores executiion times between begin() and end() functions |
| Functions | |
| Profiler | Constructor function for Profiler class |
| begin | Sets begin point for a given label. |
| calcAverages | Calculates average time for duplicates. |
| end | Sets end point for a given label. |
| mark | Sets a bookmark entry. |
| getSummaryArray | returns an array of all the entries. |
| getSummaryHtml | returns an HTML summary of all the entries. |
| getSummaryText | returns a text summary of all the entries. |
Myna.Profiler=function ( start )
Constructor function for Profiler class
| start | Optional, default new Date().getTime() Milliseconds since epoch to use as starting point. |
Reference to Profiler instance
Myna.Profiler.prototype.begin = function( label, time )
Sets begin point for a given label.
| label | string label for this event |
| time | Optional, default new Date().getTime() Time to record for this entry |
If an entry with this label was already pending, it is closed and a new entry is started.
Myna.Profiler.prototype.calcAverages = function()
Calculates average time for duplicates.
Replaces duplicate entries (by label) with a single summary entry with the isAverage property set. Also appends “ (Avg of X entries)” to the label where X is the number of duplicate entries.
Myna.Profiler.prototype.end = function( label, time )
Sets end point for a given label.
| label | string label for this event |
| time | Optional, default new Date().getTime() Time to record for this entry |
If no entry is pending for this label, one is created with the same time, and the entries isMark property is set to true;
Myna.Profiler.prototype.mark=function( label, time )
Sets a bookmark entry.
| label | string label for this event |
| time | Optional, default new Date().getTime() Time to record for this entry |
This is the same behavior as end when there is no begin. An entry is created with both begin and end set to time and the entry’s isMark property is set.
Myna.Profiler.prototype.getSummaryArray = function()
returns an array of all the entries.
Each entry is an object with begin and end proerties, and optionally isMark or isAverage properties.
Constructor function for Profiler class
Myna.Profiler=function ( start )
Sets begin point for a given label.
Myna.Profiler.prototype.begin = function( label, time )
Calculates average time for duplicates.
Myna.Profiler.prototype.calcAverages = function()
Sets end point for a given label.
Myna.Profiler.prototype.end = function( label, time )
Sets a bookmark entry.
Myna.Profiler.prototype.mark=function( label, time )
returns an array of all the entries.
Myna.Profiler.prototype.getSummaryArray = function()
returns an HTML summary of all the entries.
Myna.Profiler.prototype.getSummaryHtml = function()
returns a text summary of all the entries.
Myna.Profiler.prototype.getSummaryText = function()