1,025
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#define NS 1000000000
// Linux/GCC
static inline uint64_t get_cycle_count()
{
unsigned int lo,hi;
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t)hi << 32) | lo;
}
int main(int argc,char ** argv)
{
int i = 0;
uint64_t old,new;
int delayms = 700;
for(i = 0; i < 100; i++)
{
old = get_cycle_count();
usleep(delayms * 1000);
new = get_cycle_count();
printf("%u\n",(new-old)/(delayms*1000));
}
}