码迷,mamicode.com
首页 > 其他好文 > 详细

CPU计算性能测试程序

时间:2015-06-14 07:02:36      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

计算下面一系列的数学计算在1s中能执行过少次。

#include "stdio.h"
#include "time.h"

int i, j, l, k, m, jj;
jj = 2342;
k = 31455;
l = 16452;
m = 9823;
i = 1000000;

void main() {

	int warp_count = 0;
	int max_warp = 1000;
	long int count = 0;
	time_t b_second,l_second;

	time_t rawtime;
	struct tm * timeinfo;

	while(1){

		b_second = time(NULL);
		l_second = b_second+1;

		while ((b_second=time(NULL))<l_second) {
			m = m ^ l;
			k = (k / m * jj) % i;
			l = j * m * k;
			i = (j * k) ^ m;
			k = (k / m * jj) % i;
			m = m ^ l;
			m = m ^ l;
			i = (j * k) ^ m;
			k = (k / m * jj) % i;
			m = i * i * i * i * i * i * i; // m=k*l*jj*l;
			m = m ^ l;
			k = (k / m * jj) % i;
			l = j * m * k;
			i = (j * k) ^ m;
			l = (k / m * jj) % i;
			m = m ^ l;
			m = m ^ l;
			i = (j * k) ^ m;
			k = (k / m * jj) % i;
			m = k * k * k * k * k - m / i;

			count++;
		}
		
		
		time(&rawtime);
		timeinfo = localtime (&rawtime);
		printf("Time: %s ", asctime (timeinfo));
		printf("%ld\n",count);
		
		count=0;
		warp_count++;
		if(warp_count==max_warp)
			break;
	}
}


CPU计算性能测试程序

标签:

原文地址:http://blog.csdn.net/x_i_y_u_e/article/details/46487619

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!