 |
|
 |
Hi
I use your code in a program that I'm going to release in the PD.
Is there a particular license?
Accompanied paper:
Acknowledgment statement: "Timing routines provided by Laurent Guinnard, CodeProject"
John
|
|
|
|
 |
|
 |
Hi John,
You may use the code without even asking. I appreciate the acknowledgment statement but it is not needed. You are free to remove it!
Thanks,
Laurent
|
|
|
|
 |
|
 |
there is only a Duration.h file in the zip download
should there be a .c file. Im using g++ on linux....
|
|
|
|
 |
|
 |
In the first few lines '...using the Windows high precision timer...'
How, pray, is Linux going to use a Windows function?
Dave Cross
|
|
|
|
 |
|
 |
Can I write my own profiling code using this kind of timer. I need to get data from parallel/serial port with the resolution of minimum of 1ms. Can any body tell me how can I do it.
|
|
|
|
 |
|
 |
Did almost everything I needed except for a live duration check.
inline double CDuration::GetDurationLive(void) const
{
LARGE_INTEGER liTempStop;
QueryPerformanceCounter(&liTempStop);
return (double)(liTempStop.QuadPart-m_liStart.QuadPart-m_llCorrection)*1000000.0 / m_llFrequency;
}
As well if you put the constructor code in a Reset function, you can reuse the object over and over. Very awesome.. thanks.
|
|
|
|
 |
|
 |
You say in the article that GetDuration returns milliseconds. But in the example, you divide the returned value by 1000 in order to display it as milliseconds I think something is wrong somewhere!
|
|
|
|
 |
|
 |
Oops sorry, I should clean my glasses!
I read milli- instead of micro-
|
|
|
|
 |
|
 |
I love little pieces of code like this.
Just plug them right in and they work
Regards,
Simon Hughes
|
|
|
|
 |
|
 |
There are not so many c++ classes in the web to measure precise period of time... and this is the best I found! I used it a lot!
Regards,
Dlt75
|
|
|
|
 |
|
 |
Hi
A long time ago (Feb. 1999), I read an article by Chih-Hao Tsai of the University of Illinois at Urbana-Champaign.
He was using Windows 95, so the high res timer wasn't available. Also, if anyone needs a precise timer on an older OS, they might be interested in the following. He used the multi-media timer (in winmm.lib) to get a millisecond accurate timer.
His article is unfortunately no longer where it once was (http://casper.beckman.uiuc.edu/~c-tsai4/cogsci/millisecond.html). His summary was as follows:
"Virtually all cognitive psychology experiments require a millisecond resolution timing routine. In the good old MS-DOS days, it was easy to achieve this by increasing the frequency of hardware interrupt IRQ0 (int 8h), at the cost of increased instability of the whole system. Today, most people have already moved from MS-DOS to Windows 95 operating system. Since Windows 95 a such a complex system, in general a programmer cannot (or is not allowed to) intrude into lower levels of the system.
In fact, both the standard C run-time library and the Win32 API provide some timing functions. But we do not know how accurate they are. Two run-time library functions and two Win32 API functions from Microsoft Visual C++ Version 4.0 were tested on a Windows 95 machine with a standardized procedure for their quality (in terms of the resolution they can achieve). It was found that the two run-time library functions were basically at the same precision level: 18.2 Hz (resolution = 55 ms). The two Win32 API functions performed better than the run-time library functions, but only one of them reached near-millisecond resolution. It was concluded that only the Multimedia Timer is qualified to be used in psychological experiments."
I still have the code samples he wrote to test the timers as well if anyone's interested.
|
|
|
|
 |
|
 |
The Start() function includes a call to Sleep(0), which causes the calling thread to give up the remainder of its time slice and yield to any other thread of equal or greater priority:
inline void CDuration::Start(void)
{
Sleep(0);
QueryPerformanceCounter(&m_liStart);
}
So, if using CDuration in a multithreaded application, you might not get the results you expect since you'll get an automatic thread switch.
|
|
|
|
 |
|
 |
Additionally, the "Sleep(0)" gives a false sense of security for time measurements.
It works often, but fails silently (high priority background tasks, slightly exceeding the time slice, etc.)
For reasonable timings, the execution has to be repeated.
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
 |
|
 |
1. Don't use "Sleep", use "SwitchToThread" it's a much lighter weight method of yeilding.
2. The IDEA is to give up your time slice and it has NOTHING to do whether your application is multithreaded or not. Any thread on the system can take the time slice.
3. You can set your thread to be high priority or real time priority to prevent interruption. However there are still things called "interrupts" that can occur and obscure your timings, so definately take lots of measurements.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
 |
|
 |
It's simple & sooo easy to use ... but that's what makes it excellent. Good stuff!
Ralph Wetzel
www.irw.cc
|
|
|
|
 |
|
 |
I use it all the time! It's the simplest way to measure performance accurately, I love it!
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
 |
|
 |
Much easier to use and understand than most of the others out there.
|
|
|
|
 |