Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-03-24 14:21:19


Russell Hind wrote:

>I've just run this quickly on my PIII 800 running Win2K SP3 and worse
>case for 1,000,000 calls to QueryPerformanceCounter was 1.92seconds,
>usually between 1.55 and 1.65 seconds (10 runs).

I tied it on a 1.8 giga-hertz Pentium 4M, running XP Pro, with very similar
results: 1.48 seconds regardless of whether it was a release or debug
build. Although I was a bit surprised the faster machine didn't cause a
larger difference.

But here is the surprise - when I ran the same test on a 2.0 giga-Hertz
Pentium 4, running Win2K SP2, it took around 4.5 seconds. See below.

I wonder if these machines could be using very different timing chips,
having nothing to do with the CPU speed? That would explain why timings are
hard to reproduce from one machine to another.

Anyhow, Windows is still producing very erratic results when it comes to
timing. That's OK, as long as whatever you are trying to time takes a great
deal longer than this variable timing overhead.

--Beman

=== details ===

First time on each line - no load on CPU.
Second time, another process in a tight loop

Borland
   debug 4.45899 5.93795
   release 4.4701 5.96726

Metrowerks
   debug 4.46496 5.90992
   release 4.45852 5.95018

GCC
   debug 4.44756 5.94334
   release 4.50903 5.89241

Intel
   debug 4.45704 5.92938
   release 4.44913 5.95612

VC++ 6.0
   debug 4.48012 5.9725
   release 4.46184 5.91715

VC++ 7.0
   debug 4.4594 5.91257
   release 4.45025 5.98312

>
>#include <windows.h>
>#include <iostream>
>int main(int argc, char* argv[])
>{
>LARGE_INTEGER Start, End, Temp;
> QueryPerformanceCounter(&Start);
> for (unsigned int i = 0; i < 1000000; ++i)
> {
> QueryPerformanceCounter(&Temp);
> }
> QueryPerformanceCounter(&End);
>
>LARGE_INTEGER Frequency;
> QueryPerformanceFrequency(&Frequency);
>
>double Time = (static_cast<double>(End.QuadPart) - Start.QuadPart) /
>Frequency.QuadPart;
> std::cout << Time << std::endl;
> return 0;
>}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk