Hi All:
Could any one be kind to give me some explanation about CPU usage of
a process?
Recently, I was testing some Float point/Communication intensive
programs. To evaluate performance, I use time/top to monitor. I often
found in
top that a process 's %CPU column is very high, e.g. > 90%,
%CPU %MEM
1086 user 1 0 1372 1372 384 S 0 91.4 2.1 0:00 foo
But in top's lines summarize the system, it shows a very low user time
e.g.
CPU states: 18.9% user, 78.1% system ...
I guess it is due to the system calls(some tcp/ip session) embedded in
these programs.
(1)
Now I am confused: What kind of operations be counted as system CPU
usage, and what kind be counted as User CPU?
Is is ture that all the dynamically linked module provided by
system(libc.so, etc.) consists the %system and all static modules and
the program itself consists the %User ?
(2)
If it is true, how can I profile these program?
I tried gprof and found it can only profile functions exactly defined in
that program. For example, even the very common sqrt() could not be
profiled.
The information gcc -pg provided is so limited that I can hardly know
what exactly happend to affect time consuming.
for example:
I write a trivial program calling sqrt, and use:
time foo
, find it runs 20 seconds,
but when I gprof it, it reports total time is 4 seconds, sqrt's time is
excluded. it is hardly useful information.
Could any one recommend some way to bypss it?
Thanks in advance.
Pan Xing