Myna. Profiler

Stores executiion times between begin() and end() functions

Detail

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.

Example

<%
$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
Summary
Myna. ProfilerStores executiion times between begin() and end() functions
Functions
ProfilerConstructor function for Profiler class
beginSets begin point for a given label.
calcAveragesCalculates average time for duplicates.
endSets end point for a given label.
markSets a bookmark entry.
getSummaryArrayreturns an array of all the entries.
getSummaryHtmlreturns an HTML summary of all the entries.
getSummaryTextreturns a text summary of all the entries.

Functions

Profiler

Myna.Profiler=function (start)

Constructor function for Profiler class

Parameters

startOptional, default new Date().getTime() Milliseconds since epoch to use as starting point.

Returns

Reference to Profiler instance

begin

Myna.Profiler.prototype.begin = function(label,
time)

Sets begin point for a given label.

Parameters

labelstring label for this event
timeOptional, default new Date().getTime() Time to record for this entry

Detail

If an entry with this label was already pending, it is closed and a new entry is started.

calcAverages

Myna.Profiler.prototype.calcAverages = function()

Calculates average time for duplicates.

Detail

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.

end

Myna.Profiler.prototype.end = function(label,
time)

Sets end point for a given label.

Parameters

labelstring label for this event
timeOptional, default new Date().getTime() Time to record for this entry

Detail

If no entry is pending for this label, one is created with the same time, and the entries isMark property is set to true;

mark

Myna.Profiler.prototype.mark=function(label,
time)

Sets a bookmark entry.

Parameters

labelstring label for this event
timeOptional, default new Date().getTime() Time to record for this entry

Detail

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.

getSummaryArray

Myna.Profiler.prototype.getSummaryArray = function()

returns an array of all the entries.

Detail

Each entry is an object with begin and end proerties, and optionally isMark or isAverage properties.

getSummaryHtml

Myna.Profiler.prototype.getSummaryHtml = function()

returns an HTML summary of all the entries.

getSummaryText

Myna.Profiler.prototype.getSummaryText = function()

returns a text summary of all the entries.

Myna.Profiler=function (start)
Constructor function for Profiler class
Myna.Profiler.prototype.begin = function(label,
time)
Sets begin point for a given label.
Myna.Profiler.prototype.calcAverages = function()
Calculates average time for duplicates.
Myna.Profiler.prototype.end = function(label,
time)
Sets end point for a given label.
Myna.Profiler.prototype.mark=function(label,
time)
Sets a bookmark entry.
Myna.Profiler.prototype.getSummaryArray = function()
returns an array of all the entries.
Myna.Profiler.prototype.getSummaryHtml = function()
returns an HTML summary of all the entries.
Myna.Profiler.prototype.getSummaryText = function()
returns a text summary of all the entries.
Global instance of Myna.Profiler.