Solved

How to measure CPU time?

Posted on 1998-12-24
3
767 Views
Last Modified: 2013-11-15
Often in research paper, the author compares
the execution time of a algorithm by plotting
CPU time vs the input data (e.g number
of elements to be processed).
How is CPU time determined?

In Window NT Task Manager, in the "Processes" property page
there is a column on "CPU time" for the various processes.
How do we interprete these numbers?
0
Comment
Question by:leowlf
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1181034
In research papers, the CPU time is a theoretical unit of time. Basically, each atomic statement is treated as one unit of time. A statement in C++ would be one unit of time, i.e. assuming i is of type integer,

  i = 3;

would be O(1) (time complexity of 1).

But a for loop would be measured by the number of times through the loop:

  for (int j = 0; j < 10; j++)
  {
    i = 3;
  }

This would be O(10) because i = 3 takes O(1) and the for loop gets executed 10 times. Therefore the overall loop is O(10). In general if there are n iterations through a loop and the statement inside the loop is O(1), then the time complexity of the loop is n * O(1), which is O(n).

But these are all theoretical units of CPU time. On NT, the CPU time is the amount of time in seconds spent executing the statements in the program. These are real times and is dependent on the CPU in the machine.

These times have a relationship to the theoretical CPU units of time, but to calculate it would be near impossible because there are too many things that can change it.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1181035
O(10) is the same as O(1)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1181036
For NT, you can use the GetProcessTimes() function.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now