GetTickCount

  • Thread starter Chad Z. Hower aka Kudzu
  • 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
 
C

Christoph Wille

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
 
C

Chad Z. Hower aka Kudzu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top