mirror of https://github.com/hmatuschek/libsdr
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
560 B
C++
47 lines
560 B
C++
#include "cputime.hh"
|
|
|
|
using namespace UnitTest;
|
|
|
|
|
|
CpuTime::CpuTime()
|
|
{
|
|
}
|
|
|
|
|
|
void
|
|
CpuTime::start()
|
|
{
|
|
this->_clocks.push_back(clock());
|
|
}
|
|
|
|
|
|
double
|
|
CpuTime::stop()
|
|
{
|
|
// measure time.
|
|
clock_t end = clock();
|
|
|
|
// Get time-diff since start:
|
|
double dt = end-this->_clocks.back();
|
|
dt /= CLOCKS_PER_SEC;
|
|
|
|
// Remove start time from stack:
|
|
this->_clocks.pop_back();
|
|
|
|
// Return delta t:
|
|
return dt;
|
|
}
|
|
|
|
|
|
double
|
|
CpuTime::getTime()
|
|
{
|
|
clock_t end = clock();
|
|
|
|
// get diff:
|
|
double dt = end - this->_clocks.back();
|
|
dt /= CLOCKS_PER_SEC;
|
|
|
|
return dt;
|
|
}
|