Boost logo

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)

  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 (

Boost list run by bdawes at, gregod at, cpdaniel at, john at