Forum Discussion
Jason_Heath_432
Nimbostratus
May 06, 2011Is microsecond precision available in an iRule?
I am trying to get to microsecond precision in an iRule I am working on.
Based on reading the Tcl docs that I found a link to on this site (http://tmml.sourceforge.net/doc/tcl/ind...
spark_86682
May 12, 2011Historic F5 Account
On my 10.1.0 box, "clock clicks" returns microseconds. Here's an example:
set a1 [clock clicks]
set b1 [clock clicks -milliseconds]
after 10
set a2 [clock clicks]
set b2 [clock clicks -milliseconds]
after 100
set a3 [clock clicks]
set b3 [clock clicks -milliseconds]
after 1000
set a4 [clock clicks]
set b4 [clock clicks -milliseconds]
log local0. "As: $a1 $a2 $a3 $a4"
log local0. "Bs: $b1 $b2 $b3 $b4"
log local0. "a2-a1: [expr $a2 - $a1] a3-a2: [expr $a3 - $a2] a4-a3: [expr $a4 - $a3]"
log local0. "b2-b1: [expr $b2 - $b1] b3-b2: [expr $b3 - $b2] b4-b3: [expr $b4 - $b3]"
and here's what it logs:
As: -1076552924 -1076543381 -1076442893 -1075443255
Bs: -426278316 -426278306 -426278206 -426277206
a2-a1: 9543 a3-a2: 100488 a4-a3: 999638
b2-b1: 10 b3-b2: 100 b4-b3: 1000
The microseconds counts each round to the number of milliseconds that we waited, and that were measured. The negative numbers are because Tcl is presenting unsigned numbers as signed numbers, but the subtraction math still works out, so don't be fooled by that. However, this also means you won't be able to measure durations of more than 2^31 microseconds, which is about 35 minutes.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects