Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
This is my understanding.
You want to add the user and kernel times together.
User time is the time the program spent doing its stuff. Kernel time is
time spent doing tasks that the program has given to the kernel. This
includes things like writing to files. Any function call from your
program whose man page is from section (2) is work done by the kernel. So
this would include things like "write", "open", etc. So a "printf"
command is not a kernel command, but on the other hand the "printf"
function includes a lot of "write" commands in it, so while the execution
of the printf command itself is part of user time, it will make kernel
calls and use up kernel time.
I am guessing that your program does a lot of disc input or output.
Somehow the C++ program, being written by hand, perhaps uses the dic
inefficiently, whereas the python program uses some built in functions
which have been well designed to write to the dic efficiently.
What does your program do?
On Fri, 3 Nov 2006, Mike Miller wrote:
We have written a program in C++ and we have also written it with a slightly
different algorithm in Python. We want to see how much slower the Python
program is than the C++ program. We get these results:
Python:
------
real 10m43.357s
user 9m51.050s
sys 0m23.420s
C++:
------
real 8m16.668s
user 5m38.360s
sys 2m37.780s
The thing I'm trying to understand is what the differences are in the three
kinds of timings. "real" is pretty easy to understand, but it is the least
useful of the three times because it depends heavily on system load. This
was extracted from "man time" on GNU/Linux:
When the -p option is given the (portable) output format
real %e
user %U
sys %S
is used.
%E Elapsed real time (in [hours:]minutes:seconds).
%e (Not in tcsh.) Elapsed real time (in seconds).
%S Total number of CPU-seconds that the process spent in kernel mode.
%U Total number of CPU-seconds that the process spent in user mode.
Now I just need a more thorough understanding of "kernel mode" and "user
mode" -- know any references?
What I'm really interested in knowing is how the programs would compare in
elapsed time under optimal conditions -- no other process competing for CPU,
disk, etc. What would come closest to answering my question? Should I just
add together the %S and %U times (kernel-mode seconds plus user-mode
seconds)? Does that seem right?
Any tips will be appreciated. Thanks.
Mike
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members