CPU tick counter

时间:2015-01-01 23:46:58   收藏:0   阅读:389
#define rdtscll(val) __asm__ __volatile__ ("rdtsc" : "=A" (val))

example

#include<stdio.h>
int i;
unsigned long e;
#define as(p) __asm__ __volatile__ (p)
#define rdtscll() as("rdtsc")
int main(void)
{
	rdtscll();
	as("movl %eax,%ecx");
	rdtscll();
	as("subl %ecx,%eax");
	as("movl %eax,e");
	printf("duration:%lld\n", e);
	return 0;
}

  

原文:http://www.cnblogs.com/tmzbot/p/4197950.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!