 |
|
 |
There is a problem in using this class with laptops and some desktops that have their power management scheme configured to adjust processor speed based on load. If the clock speed is reduced or increased by the power management system, the class methods return incorrect time values. I believe disabling processor speed changes before using this class would solve the problem. Anyone know the "correct" way to do this, and how to set it back?
Neil
|
|
|
|
 |
|
 |
Hello
I suppose at the time of the writing of this article computers did not support changing the CPU clock frequency dynamically.
But on today's CPU's you should NOT use the code in this article anymore!
You will definitely get wrong results when the CPU is throttling.
If a millisecond resolution is enough, the easiest method is using timeGetTime() after setting timeBeginPeriod(1).
For higher resolutions use QueryPerformanceCounter() and QueryPerformanceFrequency() instead!
These functions are guaranteed to use constant frequencies.
The OS will check to see if the system has a high performance clock built-in. If it has and the system has no energy saving mechanism like Cool&Quite, SpeedStepping Technology in it, QueryPerformanceCounter() will take advantage of this clock, which is most likely the processor clock. Otherwise, the timer will use another constant frequency clock like the chipset, BIOS or the power management timer.
If for any reason (which is not recommended) you still insist to use RDTSC for time measurement you can use the struct PROCESSOR_POWER_INFORMATION to obtain the current processor (=real) CPU speed.
ATTENTION: It is theoretically possible that two cores of a multi-core CPU run with different speeds. So using QueryPerformanceCounter() is the only secure solution if you need high accuracy!
Elmü
|
|
|
|
 |
|
 |
I have a pointer to a CPUTicker object in a derived CWinThread class. The object is allocated in InitInstance, and is deallocated in ExitInstance.
All of my calls work correctly, but when the thread goes to shutdown, I am receiving memory check errors everywhere when I issue a "delete m_pCPUTicker;"
Should I be able to run this class in a thread, or does it have to be called in the main process? I am using it primarily to get the CPU frequency.
Jim
QTExtender - The OFFICIAL addon for QuoteTracker.
|
|
|
|
 |
|
 |
Ya, I would not expect there to be any problems there. 2 suggestions:
1. Make sure you have the latest version from my web site www.naughter.com.
2. Get the debugger out, and take it from there
|
|
|
|
 |
|
 |
I did find an apparent workaround for the version found here on CodeProject; I allocated the CCPUTicker object on the heap within the main process, and then passed a pointer of the CCPUTicker object to my CWinThread.
It appears to be working fine.
Thanks again for great work.
Jim
QTExtender - The OFFICIAL addon for QuoteTracker.
|
|
|
|
 |
|
 |
How do I change the system time so that "time" passes on the computer at a different rate than real time. In other words, how do I slow down or speed up the date/time system clock rate? Thanks.
|
|
|
|
 |
|
 |
System time on the computer is produced by divided the PC counter by two number, so you can change the two number in order to change the system time!The placement of the two number is in the port 0x43 and 0x45(maybe, I forget it)!
If you speed up the system time you will feel cool when you play some game in the internet for you are very fast!!!
|
|
|
|
 |
|
 |
hi,
i am very new in c++ programming. can i use any functions which returns me the system date & for using that date can i generate the calender for the current month & also for the following ones.. if yes can u send me the code for that .. please
my email is
khali_pk@yahoo.com
thank U.
|
|
|
|
 |
|
 |
I just want to make a time delay for about 0.00002 second. I tried to use your tick.Measure() and tick.GetTickCountAsSeconds(), but failed.
How can I do? I appreciate any suggestion.
Julia
|
|
|
|
 |
|
 |
Simple. In Windoze you can't. It is not a real-time OS. In fact, it's not even remotely close to a real-time OS.;)
|
|
|
|
 |
|
 |
I just want to make a time delay for about 0.00002 second. I tried to use your tick.Measure() and tick.GetTickCountAsSeconds(), but failed.
How can I do? I appreciate any suggestion.
Julia
|
|
|
|
 |
|
 |
I find that setting priority to time critical, then using "GetPerformanceFrequency" / "GetPerformanceCounter" standard MSVC++ 6 functions does this for me - my freq. is ~ 1mHZ for this counter, so you should find this resolution easy in your application.
Of course, busy waiting on a counter is not "polite" - but sometimes it just needs to be done.
|
|
|
|
 |
|
 |
Has anybody seen any good routines that measure seek time, and track switching times on hard drives? There are so many disk caches and buffers in Windows that you can't get an accurate read. I have TASM and thought there must be some simple ASM instructions to bypass the cache?
|
|
|
|
 |
|
 |
Has anybody seen any good routines that measure seek time, and track switching times on hard drives? There are so many disk caches and buffers in Windows that you can't get an accurate read. I have TASM and thought there must be some simple ASM instructions to bypass the cache?
|
|
|
|
 |
|
 |
Often while getting the time I'd like to get the current time without making it a two-step operation.
One simple alternative is adding another method (any name'll do):
__int64 GetImmediateTickCount();
Which simply calls the two (measure + get) methods.
Or Measure could have return type of __int64 instead of void:
__int64 Measure();
Or it could have a return type of const CCPUTicker & so it
could be chained:
const CCPUTicker & Measure();
Then example calls could look like:
__int64 UpTicks = MyTicker.Measure().GetTickCount();
or
double UpSeconds = MyTicker.Measure().GetTickCountAsSeconds();
Or is the overhead of a non-void return type unacceptable?
Rufus
|
|
|
|
 |
|
 |
I've posted an update on my web site (www.naughter.com) which uses:
__int64 Measure();
|
|
|
|
 |
|
 |
The concept of the class is good, but I thought that
QueryPerformanceCounter is an safe way to do an RDTSC if the right processor is installed. Why not use this functions in your class. You use QueryPerformanceCounter/QueryPerformanceFrequency already when you calculate the processor frequency
|
|
|
|
 |
|
 |
Only the Multiprocessor HAL of NT and Windows 2000 uses the RDTSC instruction. On all other versions of NT/2000, you just get a multiple of the standard PC Timer c. 1.x Mhz.
My code will work on any Win32 platform and will give you a resolution of the processor clock speed
|
|
|
|
 |
|
 |
I, too, had assumed that QueryPerformanceCounter always used RTDSC on a Pentium processor. Now I have to find out what our Windows CE does. Anyone know?
|
|
|
|
 |