#ifndef TIMER_HPP_
#define TIMER_HPP_
class Timer
{
typedef unsigned __int64 Time;
static const Time FREQ = 2200000000;//CPU 频率 相当于2.2GHZ
Time time_;
static Time rdtsc()
{
__asm rdtsc
}
public:
Timer() : time_( rdtsc() )
{}
void restart()
{
time_ = rdtsc();
}
double diff() const
{
return (double)( rdtsc() - time_ ) / FREQ;
}
};
#endif//TIMER_HPP_