|
Boost : |
From: Preston A. Elder (prez_at_[hidden])
Date: 2005-02-11 20:24:16
On Fri, 11 Feb 2005 20:12:08 -0500, christopher diggins wrote:
> Does "your task" here mean the current thread or does it mean the
> current process (or does it depend)?
Either or.
> Thank you very much for the explanation. What advantage would
> wall-clock-time have for profiling tasks?
It would allow you to include how much time is spent sleeping or blocked
in your profiled time. Ordinarily, when a task goes to sleep or blocks
for any reason (disk I/O, waiting for a lock, etc) the kernel cuts short
the process/thread's timeslice, meaning std::clock() would not count
it, wall_clock would.
For example:
#include <unistd.h>
int main()
{
int i;
for (i=0; i<5; ++i)
sleep(1);
return 0;
}
results in:
$ time ./blah
real 0m5.012s
user 0m0.001s
sys 0m0.001s
As I said, I can see advantages for both - sometimes you want to know how
much of your time is in a specific area of code (including waiting for
stuff), and sometimes you want to know how expensive a piece of code (from
a CPU perspective) is.
-- PreZ :) Founder. The Neuromancy Society (http://www.neuromancy.net)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk