GetTickCount

  • Thread starter Thread starter Chad Z. Hower aka Kudzu
  • Start date Start date
C

Chad Z. Hower aka Kudzu

I have some code that is calling GetTickCount in the Win32 API. Currently I
have it calling out direct but I'd like to port this little last piece to a
full .net API. Ive searched MSDN and cannot find any .net replacement for it.

What should I use to replace this?


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
Taken from my German article (http://www.aspheute.com/artikel/20011206.htm),
here is a high accuracy timing class (GetTickCount is not really good for
taking performance measurements; if you are using GetTickCount for something
else, then this solution might not help you at all):

public class PerfTiming
{
[DllImport("KERNEL32")]
public static extern bool QueryPerformanceCounter(ref Int64 nPfCt);

[DllImport("KERNEL32")]
public static extern bool QueryPerformanceFrequency(ref Int64 nPfFreq);

protected Int64 m_i64Frequency;
protected Int64 m_i64Start;

public PerfTiming()
{
QueryPerformanceFrequency(ref m_i64Frequency);
m_i64Start = 0;
}

public void Start()
{
QueryPerformanceCounter(ref m_i64Start);
}

public double End()
{
Int64 i64End=0;
QueryPerformanceCounter(ref i64End);
return ((i64End - m_i64Start)/(double)m_i64Frequency);
}
}

Chris
MVP ASP.NET
 
Christoph Wille said:
Taken from my German article
(http://www.aspheute.com/artikel/20011206.htm), here is a high accuracy
timing class (GetTickCount is not really good for taking performance
measurements; if you are using GetTickCount for something else, then
this solution might not help you at all):

Its low res in most cases. In one case high res is preferred, and in our
Win32 version we are using it. In our .net version it would be nice but not
required. Ill take a look at the article, however we are trying at all costs
to avoid any unmanaged calls which yours appears to use (SAme as we are using
for Win32)


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
Back
Top