nAutoIT Posted August 18, 2011 Share Posted August 18, 2011 Function Reference TimerInit -------------------------------------------------------------------------------- Returns a timestamp (in milliseconds). $time1 = TimerInit() sleep(3000) $time2 = TimerInit() MsgBox(1,"",$time1 & @CRLF & $time2 & @CRLF & TimerDiff($time1) & @CRLF & TimerDiff($time1 + 5000000)) MsgBox: 21810363484 21821059638 2988.2644302558 1591.46427828118 TimerInit returns a timestamp in 0.0003 milliseconds? Is Sleep() or TimerDiff() inaccurate? Link to comment Share on other sites More sharing options...
monoscout999 Posted August 18, 2011 Share Posted August 18, 2011 (edited) the diff is about 2988.2644302558?? you want to be more accurate than that?This don`t seems to be correct.. but i am not sure.TimerDiff($time1 + 5000000)The _TimeInit() function from the timer.au3 library "Retrieves the current value of the high-resolution performance counter." acourding MSDN Edited August 18, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2011 Moderators Share Posted August 18, 2011 nAutoIT,I am not quite sure what you are trying to prove with that. Remember that AutoIt is an interpreted language so that it takes a finite time to parse each line when it is needed. Plus your CPU may or may not be busy at the very moment you try to get the timestamp or measure the Sleep.Here is a small script which shows a couple of variants on TimerDiff to show how little they differ:$iDelay = 3000 ConsoleWrite("Running!" & @CRLF) For $i = 1 To 5 ; Here we get the time difference first and then display it $iTime = TimerInit() Sleep($iDelay) $nDiff = TimerDiff($iTime) ConsoleWrite("Diff first: " & $nDiff & @CRLF) ; Here we get the time difference while we display it $iTime = TimerInit() Sleep($iDelay) ConsoleWrite("Diff last: " & TimerDiff($iTime) & @CRLF) NextWhen I run this I get values betwen 3000.10ms and 3004.05ms - good enough for me. Can you detect 4ms? Basically TimerInit/TimerDiff and Sleep are more than accurate enough for humans and pretty accurate for computers. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nAutoIT Posted August 18, 2011 Author Share Posted August 18, 2011 A 14 digit number isn't very accurate if the last 12 digits are wrong, based on the presumption that Sleep(3000) delays for >=3000ms. TimerDiff being accurate to 0.1 Seconds is ok for my needs, just beeing curious. Link to comment Share on other sites More sharing options...
nAutoIT Posted August 18, 2011 Author Share Posted August 18, 2011 I am not trying to prove anything, i try to understand the results i got. I was surprised, that the TimerDiff is <3000ms, so i wondered if Sleep, or TimerDiff is causing it. If i understand your indirect answer correctly, it could be both. The more important thing for me is: Is the Function Reference wrong, or do i not get it? Dont want to sound rude or anything, English isnt my first language. Just asking out of curiosity. Link to comment Share on other sites More sharing options...
nAutoIT Posted August 18, 2011 Author Share Posted August 18, 2011 Your script returns this: Running! Diff first: 3007.44088983376 Diff last: 3007.67835018138 Diff first: 3007.72640098113 Diff last: 3007.7107565347 Diff first: 3007.71997558349 Diff last: 3007.72137240906 Diff first: 3007.72528352067 Diff last: 3007.71746129746 Diff first: 3007.72081367883 Diff last: 3007.72081367883 Any insight why my approach yields less comprehensible results? Link to comment Share on other sites More sharing options...
monoscout999 Posted August 18, 2011 Share Posted August 18, 2011 (edited) what is wrong with the function reference? as melba23 says autoit is an interpreted languaje and it takes a time to read the lines... in your example the error is about 12 ms, maybe too much, but still tolerable, if you want to be more accurate then you should run your script with higher priority and try to not overload the CPU usage while the script is running, but personaly to me 12 ms is nothing.EDIT: Your script returns this:Running!Diff first: 3007.44088983376Diff last: 3007.67835018138Diff first: 3007.72640098113Diff last: 3007.7107565347Diff first: 3007.71997558349Diff last: 3007.72137240906Diff first: 3007.72528352067Diff last: 3007.71746129746Diff first: 3007.72081367883Diff last: 3007.72081367883Any insight why my approach yields less comprehensible results?Depends the CPU usage of that moment. Edited August 18, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2011 Moderators Share Posted August 18, 2011 nAutoIT,I assume that last post is directed at me. First, your English is fine. Second, as I tried to point out, AutoIt is not the language of choice if you want really accurate timings. For example, a Sleep with a parameter of 1-9 will still pause for 10ms. TimerDiff being accurate to 0.1 Seconds is ok for my needs In which case you shoudl have no problems at all. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nAutoIT Posted August 18, 2011 Author Share Posted August 18, 2011 what is wrong with the function reference?The function reference states, that TimerInit returns a timestamp in Milliseconds.If you compare $time1 and $time2, there is not 3000ms difference.Also TimerDiff($time1 + 5000000) results in reducing the time by ~1500ms.In which case you shoudl have no problems at all. Not with my code, but with not understanding. Guess im just naturally curious. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2011 Moderators Share Posted August 18, 2011 nAutoIT,The time in ms is calculated when you use TimerDiff on the value returned by an intial TimerInit, as the example for TimerInit in the Help file clearly shows. TimerInit merely gives you a timestamp - obviously not in ms because when you call it you have not started timing, so how can it measure anything? Does that satisfy your curiosity? Becasue you have certainly exhausted my patience.If you are still not happy with the Help file description, could I suggest that you make a suggest for an alternative wording here.M23P.S. And adding a value to a TimerInit timestamp will not do what you think it does - which is why I said at the beginning of all this I was unsure what you were trying to prove. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MvGulik Posted August 18, 2011 Share Posted August 18, 2011 (edited) 1) "TimerInit"..."Returns a timestamp (in milliseconds)." is just a bug in the Doc. (aka: old doc or something like that.) (already covered I see.)2) What TimerInit() returns depends on the hardware(CPU). (think I had a link to something in relation to this, but need to look it up.)n) Generally timing things around 10..1 milliseconds.---link: www.gamedev.net/forum ... Why the "QueryPerformanceFrequency" gives the poor performance in windows7Not sure if it makes sens ... it did back than. Edited August 18, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
JohnOne Posted August 18, 2011 Share Posted August 18, 2011 I believe it is a timestamp (indeed in milliseconds) from a certain point in time. When that time is, I have no Idea. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MvGulik Posted August 18, 2011 Share Posted August 18, 2011 I believe it is a timestamp (indeed in milliseconds) from a certain point in time.When that time is, I have no Idea.Anyting that's measuring something that's in some way related to a time-period can be called a timestamp. Its some CPU related tick count. Where u use the "QueryPerformanceFrequency" to normalize it to a time in miliseconds. (see Au3 Timers.au3 UDF)Start point is Computer restart/bootup. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
JohnOne Posted August 18, 2011 Share Posted August 18, 2011 So that's where it comes from eh. Of course you are right, anything can be called a time stamp, and that's what the help file calls it. And seeing as how that time stamp depicts the number of milliseconds from that point in time then I believe the help file is not a mistake to call it that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MvGulik Posted August 18, 2011 Share Posted August 18, 2011 lol. Your sure where talking about the same things here. Anywaaaay. Doc can stay the way it is. I don't mind topics like these. I just don't agree with what the doc is saying. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... 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