1

I am calling into an API that needs the elapsed ticks between 2 points. In a C# version, I use Stopwatch and utilize the ElapsedTicks method (this seems to be different than ElapsedMilliseconds obviously).

In Windows API I see GetTickCount(). However this seems to return the elapsed milliseconds, not ticks. How can I accomplish the equivalent with Windows API? (Prefer language agnostic since I might be writing a few wrappers for this).

esac
  • 24,099
  • 38
  • 122
  • 179
  • Stopwatch is a wrap of the `QueryPerformanceCounter()` API. However see [this](http://stackoverflow.com/a/12948899/1504523) and/or [this](http://stackoverflow.com/a/11537483/1504523) answer to get more details. GetTickCount wön't deliver satisfying results because of its platform dependent granularity. – Arno Oct 28 '12 at 16:31

1 Answers1

1

Stopwatch uses QueryPerformanceCounter internally, if it's available.

It determines if it's available by calling QueryPerformanceFrequency - the return value is also used to determine the frequency of the performance counter.

Joe
  • 122,218
  • 32
  • 205
  • 338
  • Out of curiosity, on what platform(s) running a C#-compiled .NET managed executable is it *not* available? CE? – WhozCraig Oct 27 '12 at 16:08
  • Can I use GetTickCount and convert that into ticks by multiplying by the processor frequency or something? – esac Oct 27 '12 at 16:09