Solved

How to measure CPU time?

Posted on 1998-12-24
3
763 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

762 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

17 Experts available now in Live!

Get 1:1 Help Now