Chinaunix首页 | 论坛 | 博客
  • 博客访问: 392068
  • 博文数量: 103
  • 博客积分: 3073
  • 博客等级: 中校
  • 技术积分: 1078
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-23 15:04
文章分类

全部博文(103)

文章存档

2012年(13)

2011年(76)

2010年(14)

分类: LINUX

2011-06-30 21:30:19

  1. 部分代码

  2. unsigned int ts,te;
  3. unsigned int sdx,edx;
  4. unsigned long long int clock_cycles;
  5. unsigned int max=1<<31;
  6. unsigned long long int max0=(unsigned long long int )max*2;

  7. __asm__ __volatile__(
  8. "rdtsc\n\t"
  9. :"=a"(ts),"=d"(sdx));

  10. //-------------some functions need to record time-----------//
  11. b

  12. __asm__ __volatile__(
  13. "rdtsc\n\t"
  14. :"=a"(te),"=d"(edx));


  15. printf("tick ax start =%u tick end=%u \n",ts, te);
  16. printf("tick dx start =%u tick end=%u \n",sdx, edx);
  17. clock_cycles=(unsigned long long)(edx-sdx)*max0 te-ts;
  18. //or clock_cycles=(unsigned long long)(edx-sdx)*0x0100000000l+ te-ts;
  19. printf("ticks=%llu\n",clock_cycles);
阅读(3106) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~