|
Home > Archive > Unix Programming > February 2006 > Measuring CPU time
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Measuring CPU time
|
|
| Wim VDM 2006-02-20, 5:54 pm |
| Hi,
I'm trying to check how much CPU time a program is using. The program
runs for at least 40 seconds before it finishes (it recieves data from
the network). I started with a simple "top -b -d 1 | grep -i 'cpu(s)'".
This showed that when the application was running, cpu usage was around
90% most of the time and very low from time to time.
I wanted something more reliable, so I used GNU time 1.7 ("time
<program>") and this is an example of the result:
0.06user 0.13system 1:25.15elapsed 0%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (846major+58minor)pagefaults 0swaps
I find the 0 values very strange. But if the other values are correct,
that means the program uses almost no CPU power.
No other program is active during the download, so why would top list a
usage of 90%?
And are there perhaps other tools that I could use to know more about
the resource usage (cpu, memory, ...) of programs?
Greetings,
Wim VDM
| |
| Thomas Maier-Komor 2006-02-20, 5:54 pm |
| Wim VDM wrote:
> Hi,
>
> I'm trying to check how much CPU time a program is using. The program
> runs for at least 40 seconds before it finishes (it recieves data from
> the network). I started with a simple "top -b -d 1 | grep -i 'cpu(s)'".
> This showed that when the application was running, cpu usage was around
> 90% most of the time and very low from time to time.
>
> I wanted something more reliable, so I used GNU time 1.7 ("time
> <program>") and this is an example of the result:
> 0.06user 0.13system 1:25.15elapsed 0%CPU (0avgtext+0avgdata
> 0maxresident)k
> 0inputs+0outputs (846major+58minor)pagefaults 0swaps
>
> I find the 0 values very strange. But if the other values are correct,
> that means the program uses almost no CPU power.
>
> No other program is active during the download, so why would top list a
> usage of 90%?
> And are there perhaps other tools that I could use to know more about
> the resource usage (cpu, memory, ...) of programs?
>
>
> Greetings,
> Wim VDM
>
Concerning the high CPU usage, it looks like the OS is doing all the
work of your program.
You could take a look at the output of vmstat and iostat to get more
information. Additionally, a profiler might help you. Depending on the
operating system you are using, there might be even more appropriate
tools...
Tom
|
|
|
|
|