#ifndef _CELLTimestamp_hpp_
#define _CELLTimestamp_hpp_
#include <chrono>
using namespace std::chrono;
class CELLTimestamp
{
public:
CELLTimestamp()
{
update();
}
~CELLTimestamp()
{
}
void update()
{
_begin = high_resolution_clock::now();
}
double getElapsedSecond()
{
return getElapsedTimeInMicroSec() * 0.000001;
}
double getElapsedTimeInMilliSec()
{
return this->getElapsedTimeInMicroSec() * 0.001;
}
long long getElapsedTimeInMicroSec()
{
return duration_cast<microseconds>(high_resolution_clock::now() - _begin).count();
}
protected:
time_point<high_resolution_clock> _begin;
};
#endif
使用举例: 用来测试1秒收多少包 1秒大约10W个包
|