Burgaud Posted June 9, 2020 Share Posted June 9, 2020 Does TimerDiff() has a maximum range of values such that local $timer = TimerInit() . . many days later, even a hibernate in between . local $duration = TimerDiff($timer) will still work, able to count the number of ms in between? Dan Link to comment Share on other sites More sharing options...
jchd Posted June 9, 2020 Share Posted June 9, 2020 (edited) Let's see. Local $t = TimerInit() ConsoleWrite(VarGetType($t) & @TAB & $t & @LF) So it's a double. 64-bit floating-point can represent every incrementing positive integer up to the value 9007000000000000 (at least) since it's in this magnitude vincinity that an ULP comes close to 1.* That many milliseconds represents about: 9007000000000 seconds 150116666666 minutes 2501944444 hours 104247685 days 285414 years Hence I don't recommend holding your breath until the value misses a single millisecond (else you have a f*ck*ng efficient hibernation technology). * EDIT: actually the max positive integral value you can store before ULP gets > 1 is 9007199254740991 (= 2⁵³ - 1), which gives you some more years to wait. Edited June 9, 2020 by jchd Burgaud 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
argumentum Posted June 9, 2020 Share Posted June 9, 2020 (edited) ..this got me thinking. ( can you hear the silence in my head ? ) ..nope, no thoughts, ... in the help file is say "The return value from TimerInit() should be treated as an opaque handle..." , hmmm, so I wrote an awesome code: Global $t = IniRead(StringTrimRight(@ScriptFullPath, 4) & ".ini", "s", "s", TimerInit()) IniWrite(StringTrimRight(@ScriptFullPath, 4) & ".ini", "s", "s", $t) ; ..i know,i know. this is a test. ConsoleWrite( TimerDiff( $t ) & @CRLF) If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then MsgBox(0, @ScriptName, "TimerDiff:" & @LF & TimerDiff( $t ), 10) and it works. So ...., is an epoch of sorts, in a measure of sorts. Can you say more about this @jchd ?. [ 2014 answer from @Mat ] "It's never actually documented what the return type is. It could change in the next release to something completely different, so ...". [ 2008 answer from @weaponx] "Time in milliseconds since last boot." ( and the test code shows to be right ). ..so I guess I have my answers PS: so is a QueryPerformanceCounter thing and for what I read it can get complicated. I've got more answers than is practical to look at, for the practical use of the function. Edited June 9, 2020 by argumentum got it Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Burgaud Posted June 9, 2020 Author Share Posted June 9, 2020 @argumentum You confused me ... 🤔 argumentum 1 Link to comment Share on other sites More sharing options...
argumentum Posted June 9, 2020 Share Posted June 9, 2020 ...you've got a perfect answer from @jchd. I had ideas of my own. To use it as a timestamp. But is the time since boot, so I can not use it as a timestamp.( the rest of the links are just me thinking out loud ) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Burgaud Posted June 9, 2020 Author Share Posted June 9, 2020 Ok... now I understand what TimerInit() is... a time since BOOT! a hibernate should not undo it. thnx! argumentum 1 Link to comment Share on other sites More sharing options...
jchd Posted June 9, 2020 Share Posted June 9, 2020 Yeah I knew it was a kinda wrapper around some performancecounter, and I seemed to remind it was an AutoIt int64. So i rechecked and no: double. Advantage: doubles are signed so the result doesn't turn nonsensical when you compute backwards timediffs. Maybe it's the only reason to use doubles. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Exit Posted June 9, 2020 Share Posted June 9, 2020 Just a small script to show the difference after a hibernate. Local $iTimer = TimerInit() MsgBox(64 + 262144, Default, "Now do a hibernate and wait some minutes." & @LF & @LF & "After resume, press ok.", 0) Local $iMilliseconds = Round(TimerDiff($iTimer)) Local $iMsec = _Mod($iMilliseconds, 1000) Local $iSec = _Mod(@extended, 60) Local $iMin = _Mod(@extended, 60) Local $iHour = _Mod(@extended, 24) Local $iDay = @extended Local $sText = "The difference between Timerinit() and Timerdiff() was" & @LF & @LF If $iDay Then $sText &= $iDay & " days" & @CRLF If $iHour + $iDay Then $sText &= $iHour & " hours" & @CRLF If $iMin + $iHour + $iDay Then $sText &= $iMin & " minutes" & @CRLF If $iSec + $iMin + $iHour + $iDay Then $sText &= $iSec & " seconds" & @CRLF If $iMsec Then $sText &= $iMsec & " milliseconds" & @CRLF ConsoleWrite($sText & @CRLF) MsgBox(64 + 262144, Default, $sText, 0) Func _Mod($dividend, $divisor = 10) Return $divisor ? SetError(0, Int($dividend / $divisor), $dividend - Int($dividend / $divisor) * $divisor) : SetError(1, -1, -1) EndFunc ;==>_Mod You may use it also without a hibernate. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now