Re: GetTickCount() performance

From: Slava M. Usov (stripit.slough_at_gmx.net)
Date: 11/13/04


Date: Sat, 13 Nov 2004 22:21:47 +0100


"Tim Roberts" <timr@probo.com> wrote in message
news:qjscp0l4tagtekhhvvkciqan35t45kn0a9@4ax.com...
> "Slava M. Usov" <stripit.slough@gmx.net> wrote:

> >Does not matter. It is always a trip to kernel mode and back, which is
> >hundreds if not thousands of cycles.
>
> Small hundreds at the most. QueryPerformanceCounter with a multiprocessor
> HALs reads the cycle counter. It is a reasonable way to measure small
> intervals.

A transition to kernel mode is not "small hundreds" except perhaps with the
most recent CPUs and the most recent OS versions. The vanilla INT-based
syscall takes a lot of CPU cycles, definitely on the wrong side of 500.
SYSENTER may be some improvement, but I do not expect orders of magnitude,
and 2K is still the boss when it comes to the sheer number of installations.

To measure sub-microsecond and microsecond intervals, rdtsc is easily the
best choice. One difficulty with this instruction is that you have to know
the CPU frequency as well, but it can be obtained -- or, in the worst case,
just measured. For hundreds of microseconds, or, with the modern multi-GHz
CPUs, tens of microseconds, QueryPerformanceCounter() may already be used.
At tens of milliseconds and beyond, GetTickCount() or
GetSystemTimeAsFileTime() are fine. I personally prefer to use the latter
ones whenever I can, often by measuring the "bulk" time of a repeated
operation, it is simple and quite often more accurate that the "advanced"
methods.

S



Relevant Pages

  • Re: GetTickCount() performance
    ... >> HALs reads the cycle counter. ... > CPUs, tens of microseconds, QueryPerformanceCounter() may already be used. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: [Perfctr-devel] Re: Enabling RDPMC in user space by default
    ... >> useless and you cannot expect user applications who just want to ... >> measure some cycles to rely on ever changing instable or non existing ... (it's not synchronized over CPUs, ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: [PATCH] [2.6] [2/2] hlist: remove IFs from hlist functions
    ... A full cache miss is extremly costly on a modern Gigahertz+ CPU because ... An CMP is extremly cheap (a few cycles at worst), ... CPUs is costly because it adds load to the interconnect. ...
    (Linux-Kernel)
  • Re: Lockless 63-bit Counter
    ... >> DCAS is possible, but this counter will be incrementing somewhere ... FSB Xeon 3.2) cycles on a Xeon platform. ... the main slowdown of your program will be the CPUs fighting ... Michael Brown ...
    (comp.lang.asm.x86)
  • Re: DSA speed vs AES speed
    ... Microseconds, at most. ... They didn't strictly say a desktop processor. ... standard 8051 is 12 cycles whcih is the time it takes to execute a "1 ... IIRC an AES implementation was thousands ...
    (sci.crypt)