Newer
Older
Russell Taylor
committed
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/Timer.h"
Russell Taylor
committed
namespace Mantid
{
namespace Kernel
{
/** Constructor.
* Instantiating the object starts the timer.
*/
Russell Taylor
committed
{
Russell Taylor
committed
}
/// Destructor
Timer::~Timer()
{}
/// Manually reset the timer.
void Timer::restart()
{
this->m_timer.restart();
}
/// Turns off the timer being reset.
void Timer::resets(const bool resets)
{
this->m_resets = resets;
}
Russell Taylor
committed
/// Returns the wall-clock time elapsed in seconds since the Timer object's creation, or the last call to elapsed
double Timer::elapsed()
{
double result = this->m_timer.elapsed();
if (this->m_resets)
this->m_timer.restart();
return result;
}
std::string Timer::str() const
{
std::stringstream buffer;
buffer << this->m_timer.elapsed() << "s";
return buffer.str();
}
std::ostream& operator<<(std::ostream& out, const Timer obj)
{
out << obj.str();
return out;
Russell Taylor
committed
}
} // namespace Kernel
} // namespace Mantid