Re: GetTickCount() performance

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Johan Nilsson (johan.nilsson_at_newsgroups.nospam)
Date: 11/17/04


Date: Wed, 17 Nov 2004 10:59:55 +0100


"Slava M. Usov" <stripit.slough@gmx.net> wrote in message
news:uyn3yoMyEHA.3844@TK2MSFTNGP09.phx.gbl...
> "Johan Nilsson" <johan.nilsson@newsgroups.nospam> wrote in message
> news:OCwASKJyEHA.1452@TK2MSFTNGP11.phx.gbl...
> >
> > "Slava M. Usov" <stripit.slough@gmx.net> wrote in message
> > news:uIqwVHyxEHA.748@TK2MSFTNGP14.phx.gbl...
> > > "Jochen Kalmbach" <nospam-Jochen.Kalmbach@holzma.de> wrote in message
> > > news:Xns959D52CE7CBB1JochenKalmbachholzm@127.0.0.1...
> > >
> > > [...]
> > >
> > > > 3. If you want to measure short intervals, you should consider to
use
> > > > QueryPerformanceCounter/Frequency
> > >
> > > Which has horrible overhead.
> >
> > On uniprocessor machines, that is. Not sure about HT ones.
>
> Does not matter. It is always a trip to kernel mode and back, which is
> hundreds if not thousands of cycles.

Cycles apart, I made some testing in the past where the ratios were
approximately 1:10 for rdtsc vs QPC on SMP and 1:80 for rdtsc vs. QPC on
uniprocessor. I'd say the difference matters depending on your requirements,
even if rdtsc clearly outperforms QPC in all cases.

// Johan



Relevant Pages

  • Re: micro-optimization
    ... Dave Hart wrote: ... the most significant change is to read the processor cycle ... As a consequence of the above I'd say using RDTSC directly instead of QPC ...
    (comp.protocols.time.ntp)
  • Re: micro-optimization
    ... Dave Hart wrote: ... As a consequence of the above I'd say using RDTSC directly instead of QPC is ... This version only uses RDTSC if QueryPerformanceCounter ...
    (comp.protocols.time.ntp)
  • Re: QueryPerformanceFrequency
    ... While rdtsc is one possible implementation, on some CPUs/systems the QPC ... needs to be implemented in a more complex manner (multiple CPUs, ...
    (microsoft.public.vc.language)
  • Re: GetTickCount() performance
    ... >> QueryPerformanceCounter takes 1,000. ... KeQueryPerformanceCounter calls ... I claimed that QPC() was "small hundreds" when using RDTSC. ...
    (microsoft.public.win32.programmer.kernel)