IchBistTod Posted March 23, 2010 Share Posted March 23, 2010 I dunno if anyone else has posted this but here it is.Very low cpu usage ~9MS off using sleep(not relative to amount of time).func _Sleep($ms) $timer = timerinit() while timerdiff($timer) < $ms sleep(1) wend endfuncMax CPU usage, exact time, down to the nanosecond(not relative to amount of time).func _Sleep($ms) $timer = timerinit() $ms = (($ms-0.1)+0.07) while timerdiff($timer) < $ms ;nothing wend endfunctell me if you have any luck with it.Green= My SleepRed=AU3 SleepTest(1000ms):1000.001079622091001.009602774941000.002566351741000.003592892441000.00102654071000.006672514531000.00256635174999.9840886192051000.001106162791000.008725595921000.0010265407999.2978461636381000.0010265407999.9989734593041000.00153981104999.9938407558211000 <<<<<<<<<<<<<<<< PERFECT!1000.017451191841000.003592892441000.000513270351000 <<<<<<<<<<<<<<<< PERFECT!999.9096644187141000.001539811041000.015398110451000.00205308139999.9938407558211000 <<<<<<<<<<<<<<<< PERFECT!1000.012831758711000.001539811041000.00564597383Test(30000ms):30000.00153981130011.338655262530000.001026540730003.294169094930000.002053081430008.3391033475as you see my sleeps are never more than ~.003 off where as AU3 sleeps can be up to ~1.0 off on a simple 1 second sleep.AU3 sleep shows much variation so when used for larger amounts of time,it can be very inaccurate.AU3 sleep is offset relevant to the amount of time the sleep is called for, neither express this attribute. [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
wraithdu Posted March 24, 2010 Share Posted March 24, 2010 (edited) FYI, AutoIt Sleep() has a minimum value of 15 ms and works in ~15 ms increments. For $j = 5 To 50 Step 5 For $i = 1 To 10 $timer = TimerInit() Sleep($j) ConsoleWrite(TimerDiff($timer) & @CRLF) Next Next Edited March 24, 2010 by wraithdu Link to comment Share on other sites More sharing options...
MvGulik Posted March 24, 2010 Share Posted March 24, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "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...
JRowe Posted March 24, 2010 Share Posted March 24, 2010 Moot. The point, that is. Mute means "without voice" or silent. As to the thread itself, monoceres has presented us with a special sleep that's accurate to 100 nanoseconds. http://www.autoitscript.com/forum/index.php?showtopic=77905 [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
wraithdu Posted March 24, 2010 Share Posted March 24, 2010 but it seems closer to 10 then 15. But thats on my side. Result might depend on the system.Yeah, the 15ms was on my Win7 x64 desktop. Just tried on my Win7 x86 laptop, and it does seem closer to 10ms increments.Sleep(0) is faster cause it's not sleeping at all (obviously). Link to comment Share on other sites More sharing options...
crashdemons Posted March 24, 2010 Share Posted March 24, 2010 (edited) Yeah, the 15ms was on my Win7 x64 desktop. Just tried on my Win7 x86 laptop, and it does seem closer to 10ms increments. Sleep(0) is faster cause it's not sleeping at all (obviously). Not so obvious to anyone reading who doesn't know the API... Just to add context to that for any readers (and yes I know this has been said thousands of times) If you use the API, Sleep(0) will give up it's time-slice to a process of equal priority and puts the current thread in a Ready state [link], so it may or may not actually "sleep" with 0. I don't know if AutoIt's Sleep() reflects the API function in that case or not. Edit: typo, logic Edited March 24, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) Link to comment Share on other sites More sharing options...
MvGulik Posted March 24, 2010 Share Posted March 24, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "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...
crashdemons Posted March 25, 2010 Share Posted March 25, 2010 (edited) Let me see If I get that in a correct perspective. If your doing a very cpu intensive task thats also hugging hogging up the system (kinda hard to do with AutoIt itself I think, Ergo: not tested), Using a sleep(0) might also (but not necessary) present a opportunity for other tasks to get some cpu time. Making the system/Os/Other-Apps somewhat more responsive.? And if there are no other apps/processes in need of some cpu time, Your process will run at just about the same speed.?What I posted was mostly just taken from the MSDN page, so it should be roughly the "correct perspective" I hope.1. Yes, for processes of the same priority.2. Yes and NoAbout 2., the MSDN article says that besides giving up it's time it puts the thread into a ready state which might not immediately continue.So, even if there were no other processes to give up the time to, it still may be delayed from continuing (possibly even after Sleep() ends).The point I was trying to emphasize though, is that Sleep(0) is not a consistent delay; so it is the one condition that cannot be made "more accurate" in the case of this thread.Correct me if I missed anything.Edit: may->might Edited March 25, 2010 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) Link to comment Share on other sites More sharing options...
MvGulik Posted March 25, 2010 Share Posted March 25, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "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...
Baraoic Posted March 25, 2010 Share Posted March 25, 2010 monoceres made a sleep down to 100 nano second sleep udf a while back http://www.autoitscript.com/forum/index.php?showtopic=77905 Link to comment Share on other sites More sharing options...
wraithdu Posted March 25, 2010 Share Posted March 25, 2010 Deja vu? 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