19 #include <drizzled/session/times.h>
20 #include <drizzled/session.h>
21 #include <drizzled/statistics_variables.h>
26 type::epoch_t Times::getCurrentTimestamp(
bool actual)
const
28 return ((actual ? boost::posix_time::microsec_clock::universal_time() : _end_timer) - _epoch).total_microseconds();
31 type::epoch_t Times::getCurrentTimestampEpoch()
const
33 return ((_user_time.is_not_a_date_time() ? _start_timer : _user_time) - _epoch).total_seconds();
36 type::epoch_t Times::getCurrentTimestampEpoch(type::usec_t &fraction_arg)
const
38 if (not _user_time.is_not_a_date_time())
41 return (_user_time - _epoch).total_seconds();
44 fraction_arg= _start_timer.time_of_day().fractional_seconds() % 1000000;
45 return (_start_timer - _epoch).total_seconds();
48 uint64_t Times::getElapsedTime()
const
50 return (_end_timer - _start_timer).total_microseconds();
53 void Times::resetUserTime()
55 _user_time= boost::posix_time::not_a_date_time;
58 boost::posix_time::ptime Times::start_timer()
const
63 boost::posix_time::ptime Times::epoch()
const
68 void Times::set_time()
70 _end_timer= _start_timer= boost::posix_time::microsec_clock::universal_time();
71 utime_after_lock= (_start_timer - _epoch).total_microseconds();
74 void Times::set_time_after_lock()
76 utime_after_lock= (boost::posix_time::microsec_clock::universal_time() - _epoch).total_microseconds();
79 type::epoch_t Times::query_start()
81 return getCurrentTimestampEpoch();
84 void Times::set_time(time_t t)
86 _user_time= boost::posix_time::from_time_t(t);
89 uint64_t Times::getConnectMicroseconds()
const
91 return (_connect_time - _epoch).total_microseconds();
94 uint64_t Times::getConnectSeconds()
const
96 return (_connect_time - _epoch).total_seconds();
99 void Times::set_end_timer(Session& session)
101 _end_timer= boost::posix_time::microsec_clock::universal_time();
102 session.status_var.execution_time_nsec+= (_end_timer - _start_timer).total_microseconds();
TODO: Rename this file - func.h is stupid.