The following code:
#include <iostream>
#include <boost/timer.hpp>
#include <unistd.h>
int main()
{
boost::timer t;
sleep(1);
std::cout << t.elapsed() << std::endl;
t.restart();
sleep(3);
std::cout << t.elapsed() << std::endl;
return(0);
}
Returns (compiled with gcc 4.2.4 on Ubuntu Linux 8.04 using boost 1.36):
andre@andre-desktop:~/test$ ./timer_test
0
0
Is this result expected? Why?
There is another timer implementation that works with sleep?
[]'s
Andre Paim Lemos