Re: GetTickCount() performance
From: Slava M. Usov (stripit.slough_at_gmx.net)
Date: 11/13/04
- Next message: Gary Chanson: "Re: GetTickCount() performance"
- Previous message: Tim Roberts: "Re: GetTickCount() performance"
- In reply to: Tim Roberts: "Re: GetTickCount() performance"
- Next in thread: Gary Chanson: "Re: GetTickCount() performance"
- Reply: Gary Chanson: "Re: GetTickCount() performance"
- Reply: Johan Nilsson: "Re: GetTickCount() performance"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Gary Chanson: "Re: GetTickCount() performance"
- Previous message: Tim Roberts: "Re: GetTickCount() performance"
- In reply to: Tim Roberts: "Re: GetTickCount() performance"
- Next in thread: Gary Chanson: "Re: GetTickCount() performance"
- Reply: Gary Chanson: "Re: GetTickCount() performance"
- Reply: Johan Nilsson: "Re: GetTickCount() performance"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|