#include "Stopwatch.h" Stopwatch::Stopwatch() { fclockTicks = 0; fclockTicks = sysconf(_SC_CLK_TCK); } Stopwatch::~Stopwatch() { } void Stopwatch::start(){ fstart = times(&ftmsStart); } void Stopwatch::stop(){ fend = times(&ftmsEnd); } double Stopwatch::getRealTime(){ double retval; retval = ((fend-fstart)/(double)fclockTicks); return retval; } double Stopwatch::getSysTime(){ double retval; retval = ((ftmsEnd.tms_stime - ftmsStart.tms_stime)/(double)fclockTicks); return retval; } string Stopwatch::formatRealTime(){ string retval; char carry[30]; sprintf(carry,"RT=%7.5f",getRealTime()); retval = carry; return retval; } string Stopwatch::formatSysTime(){ string retval; char carry[30]; sprintf(carry,"Cpu=%7.5f",getSysTime()); retval = carry; return retval; }