1

I have a command line tool which I run on Ubuntu 12.04.5 LTS. I need to calculate the cpu time for this program. I have been checking /usr/bin/time function.

command: /usr/bin/time -v -a -o timelog.dat command args

I run the same command on the same hardware for twice. The results from 2 runs are below:

1st run:

User time (seconds): 4085.50
System time (seconds): 4.75
Percent of CPU this job got: 54%
Elapsed (wall clock) time (h:mm:ss or m:ss): 2:04:19
Maximum resident set size (kbytes): 5093280
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 384474
Voluntary context switches: 436
Involuntary context switches: 628160
Swaps: 0
File system inputs: 24
File system outputs: 102936

2nd run:

User time (seconds): 2694.91
System time (seconds): 2.51
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 45:18.91
Maximum resident set size (kbytes): 5093280
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 384483
Voluntary context switches: 223
Involuntary context switches: 4321
Swaps: 0
File system inputs: 9288
File system outputs: 100136

Specs of the server CPU: Clock speed: 2.4 GHz, Turbo Speed: 2.7 GHz, 8 physical cores, 16 threads

So, in the first run the server was on full load, I had more than 16 processes. In the second run I had 7 processes. How can I be sure about the timing information I get ? Can we make a comparison between these 2 runs when the CPU usage percentage is 99% on both ? Is there another method of measuring the exact time spent for a process ? Why do I get totally different results even though /usr/bin/time function should calculate CPU time.

Any help would be greatly appreciated

Thanks in advance, Serhat

migrated from stackoverflow.com Jan 24 '15 at 2:47

This question came from our site for professional and enthusiast programmers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.