News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How can I measure time in milliseconds?

By Vassili Philippov, July 19, 2001.
Print version

Question

How can I measure time in milliseconds? It seems like CTime supports only seconds.

Answer

Unfortunally there is no good solution for that. All functions that could help are described as OEM depended. It means that on some devices they could work wrong.

One of the most simple way to measure time that works on most devices is GetTickCount function that returns number of milliseconds that have elapsed since Windows CE was started.

Source code

Here is a sample code that measures time of some action

DWORD dwStartTime = GetTickCount(); //Here are some actions that we measure DWORD dwFinishTime = GetTickCount(); CString str; str.Format(_T("The action took %d milliseconds."), (int)(dwFinishTime-dwStartTime)); AfxMessageBox(str);

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House