Ray Schumacher wrote: >In the attached test code, I get - for test in [0, .1, .01, .001, .00001] >seconds > > # 2.9us hi 5.2us low, > # 110ms hi and low, > # 16ms hi and low, > # 16ms hi and low, > # 2.9us hi 5.2us low > >Intestingly, if I un-comment the > #print '\r', >then the processor usage drops by ~11 per cent. > >If anyone has comments on these sleep() results, please enlighten me as to why. > >
What surprises you? The Win32 Sleep() function takes integer milliseconds. Thus, .00001 will round to 0, which says "give up the CPU only if a higher-priority task is waiting.". The default scheduling interval on your system is 16ms. Some Windows systems use that, some use 10ms; it depends on the HAL. Windows only checks for timer expiration when its scheduling runs, and the scheduler doesn't run any more often than that. You can reduce that to 1ms by using timeBeginPeriod (I said timeBeginTime before; that was wrong), but it will cost overall system performance, because you're getting interrupts 16x as often. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-win32
