Skip to main content
Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.

GetTickCount() Precision Argument In Lucee CFML

By Ben Nadel on
Tags: ColdFusion

The other day, while looking through some Lucee CFML documentation, I came across an example that used the built-in getTickCount() function with an argument. I've been using getTickCount() since the beginning of time and I never once noticed that it accepted an argument (at least in the Lucee CFML runtime). As such, I thought it might be worth sharing this feature more broadly.

By default, the getTickCount() function returns the milliseconds since Epoch (aka, "System Time"). This function is incredibly useful when it comes to measuring the performance of a block of code (by measuring the delta between a pre-and-post call to getTickCount()). In Adobe ColdFusion - from what I can see - this is the only invocation format. However, in Lucee CFML, you can pass-in the following arguments:

  • millisecond - equivalent to default invocation.
  • milli - equivalent to default invocation.
  • second
  • micro
  • nano

To see this in action, I've set up a quick demo:


	// Milliseconds since Epoch - the default.
	echoLine( "Default", getTickCount() );

	// Alternate formats.
	echoLine( "Millisecond", getTickCount( "millisecond" ) );
	echoLine( "Milli", getTickCount( "milli" ) );
	echoLine( "Second", getTickCount( "second" ) );
	echoLine( "Micro", getTickCount( "micro" ) );
	echoLine( "Nano", getTickCount( "nano" ) );

	// ------------------------------------------------------------------------------- //
	// ------------------------------------------------------------------------------- //

	public void function echoLine(
		required string label,
		required string value
		) {

		echo( "<dt><strong>#label#:</strong></dt><dd>#value#</dd>" );



And, when we run this Lucee CFML code, we get the following output:

Various results of getTickCount() with an argument in Lucee CFML

As you can see, the argument "second" gives us lower precision; and, the arguments "micro" and "nano" give us higher precision time values.

I don't have an immediate need for these levels of granularity - the default millisecond result for getTickCount() works well for my use-cases. But, I suppose this would be helpful for micro-benchmarks where you're trying to super-tune some block of code? Anyway, I didn't know this existed; so, I figured there are others who might be curious to know.

Reader Comments

Sadly, ACF GetTickCount() does NOT support these arguments. I love all the thoughtful adds Lucee gives us. I'm currently working on a long-running process which creates JSON packets for every user (over 30k users) and sends them to another service to sync the two. It takes about 700ms per transaction. I keep track of the processingTime per transaction as well as for each collection/batch. For the batch I have to use ms/1000 math to get seconds...not a big deal, but would be nice to pass "seconds" in as a parameter instead!

Reply to this Comment


I do like the little Lucee details. Also, over on Twitter, Zack Spitzer was saying that they are also adding this granularity to the <CFTimer> tag as well; along with the ability to get the time as a variable. I think he said it would be something like this:

<cftimer variable="duration" units="nano">
	... processing things ...

<cfoutput>Duration: #numberFormat( duration )# nanoseconds</cfoutput>

It would be an interesting way to use the timer tag.

Reply to this Comment


I had totally forgotten (blocked? wiped?) the cftimer tag from my memory. I only ever use GetTickCount() and do the math to calculate duration. That would be a super clever use of the tag though!

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Blog
Live in the Now
NEW: Some basic markdown formatting is now supported: bold, italic, blockquotes, lists, fenced code-blocks. Read more about markdown syntax »
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.