How to calculate the execution time of a particular statement or a function

30 12 2008

We could use GetTickCount Windows API function for this purpose. Actually this API function retrieves the number of milliseconds that have elapsed since the system was started.

Please look at the code snippet below.

void CheckExecutionTime()
   DWORD dw = GetTickCount();
   // we need to know the execution time of this function
   // now dw contains the execution time of ExecuteFunction()
   dw = GetTickCount() - dw;

void ExecuteFunction()
   // some lengthy operations



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: