Moderators Melba23 Posted April 19, 2014 Moderators Share Posted April 19, 2014 iCode,When I run your code on my Win7 x86 system I get the following results:Average over 100 Sleep(10): 3.3.10.2: 10.005 3.3.11.4: 10.120I think the problem lies elsewhere. 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...
Iczer Posted April 19, 2014 Share Posted April 19, 2014 I'm getting almost always 99 hits on range 15-16 ms and one to 5 to 13 ms #include <Array.au3> Local $array[1][20] For $i = 1 To 100 $t = TimerInit() Sleep(10) $n = TimerDiff($t) $array[0][Int($n)] += 1 Next _ArrayDisplay($array) Link to comment Share on other sites More sharing options...
FaridAgl Posted April 19, 2014 Share Posted April 19, 2014 As far as I know, AutoIt's Sleep() function is different than the Sleep() function in the Kernel32.dll. AutoIt uses timer to implement that, and that's exactly why the delay can't be less than 10ms. Maximum sleep time is 2147483647 milliseconds (24 days) and the minimum is 10 milliseconds. So using 1-9 will automatically default to 10 milliseconds. If you really need to sleep less than 10ms, try the other Sleep function. DllCall("kernel32.dll", "none", "Sleep", "DWORD", 1) But, seriously, use it only when you want to sleep less than 10ms. http://faridaghili.ir Link to comment Share on other sites More sharing options...
trancexx Posted April 19, 2014 Share Posted April 19, 2014 Currently the precision of Sleep depends on global Windows setting which can be influenced by any third party application. One user can really have 10ms sleep for Sleep(10), and some other can have, for example 24ms sleep period for the same call. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 There is indeed significant dispersion in timed values. Local Const $limit = 50000 Local $values[51] Local $t, $n For $i = 1 To $limit $t = TimerInit() Sleep(10) $n = Round(TimerDiff($t)) $values[$n] += 1 Next For $i = 0 To UBound($values) - 1 $t = $values[$i] If $t Then $n = Round((800 * $t) / $limit) / 8 $values[$i] = (Int($n / 8)) ? _StringRepeat(ChrW(0x2588), Int($n / 8)) : '' $n = Mod($n, 8) If $n Then $values[$i] &= ChrW(0x2588 + 8 - $n) $values[$i] &= ' ' & $t EndIf Next _ArrayDisplay($values) I've found the need to increase possible times to 50ms since I've encountered values > 35ms. The sample above was obtained while doing other foreground task. mLipok and Ascend4nt 2 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...
trancexx Posted April 19, 2014 Share Posted April 19, 2014 ^^ You are just showing off. Like: "hey people look, I can draw graph using arraydisplay". I like it. Digisoul 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 It was more fun than mere timing! It's prettier in console but that would need Unicode display. All kind of asciified statistic graphs are useful within databases, using views, ad hoc statistic functions and a bit of care. 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...
iCode Posted April 19, 2014 Share Posted April 19, 2014 @Melba23 - try both 32 and 64 bit, release and beta - i would guess you'll probably experience very different results as i and @jchd did @D4RKON3 - i agree, but just a note to others who stumble upon this that the dll call, in a tight loop with small values, will hog the CPU... ; CPU hog with small values... While 1 DllCall("kernel32.dll", "none", "Sleep", "DWORD", 1) Wend anyway, no big deal, but i think the help file should be updated to reflect the inaccuracy of Sleep at smaller values (so far it looks like values < 17 are problematic) FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 19, 2014 Moderators Share Posted April 19, 2014 (edited) iCode,This are the results I get while simultaneously streaming and doing other foreground work as well on my x86 machine:expandcollapse popupBeta Release [0]| [1]| [2]| [3]| [4]| [5]| [6]| [7]| [8]| [9]| 1140 1481 [10]| 45251 43852 [11]| 1003 1320 [12]| 544 653 [13]| 407 493 [14]| 271 371 [15]| 208 288 [16]| 169 201 [17]| 108 147 [18]| 112 103 [19]| 73 103 [20]| 61 82 [21]| 62 67 [22]| 48 66 [23]| 40 64 [24]| 32 39 [25]| 30 34 [26]| 21 43 [27]| 25 39 [28]| 22 49 [29]| 29 33 [30]| 17 36 [31]| 21 33 [32]| 16 27 [33]| 25 26 [34]| 16 30 [35]| 15 22 [36]| 20 14 [37]| 14 17 [38]| 9 15 [39]| 11 16 [40]| 15 14 [41]| 17 13 [42]| 14 17 [43]| 7 7 [44]| 3 15 [45]| 5 13 [46]| 7 9 [47]| 7 6 [48]| 5 10 [49]| 7 4 [50]|If you want to donate an x64 box for me to run tests on that I would be happy to do so. But the main point I take from this is that if you want real timing accuracy then an interpreted language is probably not the best way to go given the inherent problems. But I will add something to the Help file explaining that the timings are only approximate and under 10 is not honoured at all. M23Edit: Added comment to Help file. Edited April 19, 2014 by Melba23 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...
iCode Posted April 19, 2014 Share Posted April 19, 2014 thanks @Melba23 FYI, here's the note i made in a code snippet regarding the sleep dll call.. ; however, do NOT make the DllCall() if the sleep is going to be repeated in a tight loop, else funny things happen outside of script, such as Ctrl+L-click gets whacky when selecting multiple objects in Explorer FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences) CODE SNIPPITS: Dynamic tab width (set tab control width according to window width) 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