CFLib.org – Common Function Library Project

GetLoadTime(mes, beg)

Last updated October 10, 2002

author

Kyle W. McNamara

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
The single getLoadTime function allows you to easily return loadtimes from anywhere within your application. Utilizes the CF getTickCount function.

Return Values:
Returns a string.

Example:

<!--- begin measure app load time --->
<cfset request.tickBegin = getTickCount()>

<!--- do stuff --->
<cfloop index="x" from=1 to=15000></cfloop>

<!--- end measure app load time --->
<cfoutput>
<font size="-2">[Load Time: #getLoadTime("mil",request.tickBegin)#]</font>
<p>
<font size="-2">[Load Time: #getLoadTime("sec",request.tickBegin)#]</font>
</cfoutput>

Parameters:

Name Description Required
mes Type of measurement, either 'mil' for miliseconds or 'sec' for seconds. Yes
beg Beginning tick count. Yes

Full UDF Source:

/**
 * Measures the elapsed time (load time) from when the single function was first called to the time it was last called.
 * 
 * @param mes      Type of measurement, either 'mil' for miliseconds or 'sec' for seconds. (Required)
 * @param beg      Beginning tick count. (Required)
 * @return Returns a string. 
 * @author Kyle W. McNamara (mac@kwm.tm) 
 * @version 1, October 10, 2002 
 */
function GetLoadTime(mes,beg) {
    var measurement = 0;
    var measure_text = "";
    var tickBeginValue = 0;
    var tickEnd = 0;
    var loadTime = "";

    if (mes eq "mil") {
        measurement = 1;
        measure_text = " Milliseconds";
    }
    else if (mes eq "sec") {
        measurement = 1000;
        measure_text = " Seconds";
    }
    tickBeginValue = beg;
    tickEnd = gettickcount();
    loadTime = ((tickEnd - tickBeginValue)/measurement) & measure_text;
    return loadTime;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson