Forum Discussion
clock clicks -milliseconds overflow time?
But I can't find anywhere that explicitly says what the implementation of it is in iRules (Apart from -milliseconds is the highest resolution, and that's from memory... I can't seem to find the posting... NEDs rule is interesting though. That seems to assume that the hi res timer is an offset from the current second... Again I can't find anywhere that actually documents that though.
(Although there is a good description of hi res timers on sourceforge, and it's unambiguous, but clock clicks is IMPLEMENTATION DEPENDENT, and thus any docs there possibly aren't much use).
Fa
TIA
Hamish.
- Hamish
Cirrocumulus
And it doesn't implement the [clock milliseconds] option which is the preferred method and returns the time from epoch.. - tsoi_94459
Nimbostratus
Any fix for this? - hoolio
Cirrostratus
Tsoi, - tsoi_94459
Nimbostratus
fixed! - Hexum_117235
Nimbostratus
Greetings! - m_137079
Nimbostratus
I know this is a four year old thread but was wondering if anyone found solution for the overflow of [clock clicks -milliseconds] . We use 10.2 Version. Any insight is much appreciated
I worked a case on this back in 2012 and I just dug it up to cut & paste my findings:
---START---
Furthermore, with everything 64-bit in v11 already it looks like ‘clock clicks –milliseconds’ already does what you want. So if you use v11, you have it now with no wait and no workaround.
And yet more, there is a work around to get a millisecond timestamp:
set secs [expr {wide([clock seconds])}]
set msecs [expr {($secs * 1000) + ([clock clicks -milliseconds] % 1000)}]
That should avoid the rollover issue.
Basically ‘clock clicks –milliseconds’ returns a 64-bit value, but it is being truncated – we’re only returning the rightmost 32-bits. That’s why it doesn’t look anything like 1000 * seconds. But it is the accurate 32-bit ‘tail’. So if we shift seconds to the left ( * 1000) and then add the remainder from the milliseconds (% 1000) then you should be able to recreate the accurate millisecond timestamp.
‘clock clicks –milliseconds’ is a synonym for ‘clock milliseconds’ – when the whole value is present. It is the truncation on v10 that is munging the results.
For now I’d use that work around in v10 to get milliseconds.
---END---
Recent Discussions
Related Content
* 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