16 #ifndef STXXL_COMMON_TIMER_HEADER
17 #define STXXL_COMMON_TIMER_HEADER
24 #if STXXL_BOOST_TIMESTAMP
25 #include <boost/date_time/posix_time/posix_time.hpp>
44 #if STXXL_BOOST_TIMESTAMP
45 boost::posix_time::ptime MyTime = boost::posix_time::microsec_clock::local_time();
46 boost::posix_time::time_duration Duration =
47 MyTime - boost::posix_time::time_from_string(
"1970-01-01 00:00:00.000");
48 double sec = double(Duration.hours()) * 3600. +
49 double(Duration.minutes()) * 60. +
50 double(Duration.seconds()) +
51 double(Duration.fractional_seconds()) / (pow(10., Duration.num_fractional_digits()));
54 return GetTickCount() / 1000.0;
57 gettimeofday(&tp, NULL);
58 return double(tp.tv_sec) + tp.tv_usec / 1000000.;
75 inline timer(
bool start_immediately =
false)
76 : running(false), accumulated(0.), last_clock(0)
78 if (start_immediately) start();
106 return (accumulated +
timestamp() - last_clock) * 1000.;
108 return (accumulated * 1000.);
115 return (accumulated +
timestamp() - last_clock) * 1000000.;
117 return (accumulated * 1000000.);
124 return (accumulated +
timestamp() - last_clock);
126 return (accumulated);
149 : m_message(message),
161 <<
" after " << m_timer.seconds() <<
" seconds");
164 <<
" after " << m_timer.seconds() <<
" seconds. "
172 #endif // !STXXL_COMMON_TIMER_HEADER
~scoped_print_timer()
on destruction: tell the time
static const int bytes
number of bytes in uint_pair
double mseconds()
return currently accumulated time in milliseconds
std::string m_message
message
unsigned long long int uint64
Simple scoped timer, which takes a text message and prints the duration until the scope is destroyed...
double timestamp()
Returns number of seconds since the epoch, high resolution.
void reset()
return accumulated time
#define STXXL_BEGIN_NAMESPACE
timer(bool start_immediately=false)
double seconds()
return currently accumulated time in seconds (as double)
double useconds()
return currently accumulated time in microseconds
static double timestamp()
return current timestamp
std::string format_IEC_size(uint64 number)
Format a byte size using IEC (Ki, Mi, Gi, Ti) suffixes (powers of two). Returns "123 Ki" or similar...
scoped_print_timer(const std::string &message, const uint64 bytes=0)
save message and start timer
#define STXXL_END_NAMESPACE
uint64 m_bytes
bytes processed