13 #ifndef STXXL_TIMER_HEADER
14 #define STXXL_TIMER_HEADER
16 #ifdef STXXL_BOOST_TIMESTAMP
17 #include <boost/date_time/posix_time/posix_time.hpp>
24 #include <stxxl/bits/namespace.h>
27 __STXXL_BEGIN_NAMESPACE
33 #ifdef STXXL_BOOST_TIMESTAMP
34 boost::posix_time::ptime MyTime = boost::posix_time::microsec_clock::local_time();
35 boost::posix_time::time_duration Duration =
36 MyTime - boost::posix_time::time_from_string(
"1970-01-01 00:00:00.000");
37 double sec = double(Duration.hours()) * 3600. +
38 double(Duration.minutes()) * 60. +
39 double(Duration.seconds()) +
40 double(Duration.fractional_seconds()) / (pow(10., Duration.num_fractional_digits()));
44 gettimeofday(&tp, NULL);
45 return double(tp.tv_sec) + tp.tv_usec / 1000000.;
54 inline double timestamp();
61 inline double seconds();
62 inline double mseconds();
63 inline double useconds();
66 timer::timer() : running(false), accumulated(0.)
69 double timer::timestamp()
71 return stxxl::timestamp();
77 last_clock = timestamp();
83 accumulated += timestamp() - last_clock;
89 last_clock = timestamp();
92 double timer::mseconds()
95 return (accumulated + timestamp() - last_clock) * 1000.;
97 return (accumulated * 1000.);
100 double timer::useconds()
103 return (accumulated + timestamp() - last_clock) * 1000000.;
105 return (accumulated * 1000000.);
108 double timer::seconds()
111 return (accumulated + timestamp() - last_clock);
113 return (accumulated);
116 __STXXL_END_NAMESPACE
118 #endif // !STXXL_TIMER_HEADER