#include
static inline __u64 get_cycles(void)
{
__u32 timehi, timelo;
asm("rdtsc":"=a"(timelo),"=d"(timehi):);
return (__64)(((__u64)timehi)<<32 | (__u64)timelo);
}
调用方式
void main()
{
__u64 tick_1 = get_cycles();
//some_program
__u64 tick_2 = get_cycles();
cout<<"function running time: "<<(tick_2 - tick_1) / CPU_FRQ<<endl;
}