![]() |
Comments re High resolution replacement for Sleep - Printable Version +- PowerBASIC Users Meeting Point (http://pump.richheimer.de) +-- Forum: User to User Discussions (http://pump.richheimer.de/forumdisplay.php?fid=3) +--- Forum: Programming (http://pump.richheimer.de/forumdisplay.php?fid=7) +--- Thread: Comments re High resolution replacement for Sleep (/showthread.php?tid=74) Pages:
1
2
|
Comments re High resolution replacement for Sleep - David Roberts - 09-14-2025 I had a bit of a 'carrry on' creating post #2. I couldn't figure out the difference between 'Quick Edit' and 'Full Edit'. On one occasion, I got post #1 merging with post #2. On another occasion, I got post #2 being duplicated within itself. Would someone explain the difference? Anyway, the question is whether to use SleepX or SleepXX. I cannot answer that - only you can by trying the two source codes. On my Windows 10 machine with a Performance Counter Frequency of 10MHz and a CPU Base Frequency of 3.5GHz SleepXX is the more accurate. If you have the time, would you let me know what your Performance Counter Frequency is, your CPU Base Frequency, and a console output of the more accurate. Ta much. ![]() RE: Comments re High resolution replacement for Sleep - Stuart McLachlan - 09-14-2025 Instead of a preprogrammed Base Frequency macro, you can determine it at run time so your code is not machine specific ![]() ' Code: #COMPILE EXE RE: Comments re High resolution replacement for Sleep - David Roberts - 09-14-2025 Thanks, Stuart I am getting 'Undefined equate' on line #14 - RegOpenKeyEx RE: Comments re High resolution replacement for Sleep - Dale Yarker - 09-14-2025 Class A/class B amplifier analogy is backwards, so actually detracts from explanation of SLEEPXX. A class A amp wastes power by being half on at zero input. Typically, one, or more (in series), class A amps drive a high(er) power class B amp that has both active drive components off when input is zero. Is it too late to edit out? No comment, either way, on SLEEPXX code ATT; though better resolution is a good thing. Cheers, RE: Comments re High resolution replacement for Sleep - David Roberts - 09-14-2025 Stuart's code works if simply add: %HKLM = &H80000002??? RE: Comments re High resolution replacement for Sleep - Stuart McLachlan - 09-14-2025 (09-14-2025, 03:19 AM)David Roberts Wrote: Thanks, Stuart Sorry , I used José's includes which has the equate: %HKLM = %HKEY_LOCAL_MACHINE With PB includes, you have to specify the root key in full: retval = RegOpenKeyEx( %HKEY_LOCAL_MACHINE,"HARDWARE\DESCRIPTION\System\CentralProcessor\0" ,0,%key_query_value,hkey) RE: Comments re High resolution replacement for Sleep - David Roberts - 09-14-2025 Thanks, Dale. My taking a wrong turn on the analogies isn't relevant. The results with SleepX and SleepXX speak for themselves. Thanks, Stuart. RE: Comments re High resolution replacement for Sleep - Stuart McLachlan - 09-14-2025 Couldn't work out why replacing the macro with the function didn't work. Finally realised that I had to change /10^15 to *10^3 to get the correct values! Took a bit of time to work out that the issue was the macro substitution messing up the order of operations in the calculation. The macro is not replacing CPUBaseFreq with the VALUE of 3.5*10^9, it is replacing it with the STRING 3.5*10^9 in the source code, which resulted in a difference order of calculation and a vastly different magnitude of the result. So qTime/CPUBaseFreq became qTime/3.5*10^9 which is not the same as qTime/(3.5*10^9) (I guess the 10^15 was derived by trial and error since it has no logical basis when dividing tix by hertz ![]() RE: Comments re High resolution replacement for Sleep - David Roberts - 09-14-2025 Oops. ![]() Post #3 at the source code forum incorporates your GetBaseCPUFreq. There is no need for the offending macro now. Thank you, Stuart. RE: Comments re High resolution replacement for Sleep - Dale Yarker - 09-14-2025 "If you have the time, would you let me know what your Performance Counter Frequency is, your CPU Base Frequency, and a console output of the more accurate." Performance Counter Frequency = 10.0 Mhz CPU Base Frequency = 2.712 GHz In SLEEPXX IF <= 3 THEN removed leaving: tix qTimeNow qTarget = qTimeNow + n*CPUBaseFreq*0.001 ELSE and below removed console output: Code: Quarter of a millisecond: 0.25011 ms |