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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson