博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[C语言]CPU跑分程序
阅读量:4588 次
发布时间:2019-06-09

本文共 2404 字,大约阅读时间需要 8 分钟。

|版权声明:本文为博主原创文章,未经博主允许不得转载。

Code:

1 #include 
2 #include
3 #include
//clock()所属头文件 4 const int N_qsort=10000;//快排的数据规模 5 const int M=20000,N=50000;//整点、浮点运算的规模 6 const int N_pi=100000000;//计算圆周率的运算规模 7 double s_int,s_float,s_pi,s_sort; 8 void int_comp(void);//整点运算 9 void float_comp(void);//浮点运算 10 void pi_comp(void);//泰勒级数推论式计算圆周率 11 void Qsort(int a[],int low,int high);//快排算法 12 void qsort(void);//调用快排算法的函数 13 void panduan(); 14 void PAUSE(); 15 int main(){ 16 printf("------\n性能测试开始\n"); 17 int_comp();//整点运算 18 float_comp();//浮点运算 19 pi_comp();//泰勒级数推论式计算圆周率 20 qsort();//快速排序 21 printf("------\n测试结束\n"); 22 printf("整点运算得分:%lf\n",s_int); 23 printf("泰勒级数推论式计算圆周率运算得分:%lf\n",s_pi); 24 printf("排序运算得分:%lf\n",s_sort); 25 printf("总得分:%lf\n",s_int+s_float+s_pi+s_sort); 26 panduan(); 27 PAUSE(); 28 return 0; 29 } 30 31 void int_comp(void){
//整点加法 32 printf("整点运算测试中(运算次数为:%lf)\n",(double)M*N); 33 clock_t start,end; 34 int i,j; 35 start=clock(); 36 for(i=0;i
=high) return; 80 int first=low; 81 int last=high; 82 int key=a[first]; 83 while(first
=key) --last; 85 a[first]=a[last]; 86 while(first
<=key) ++first; 87 a[last]=a[first]; 88 } 89 a[first]=key; 90 Qsort(a,low,first-1); 91 Qsort(a,first+1,high); 92 } 93 void qsort(void){ //调用快排算法的函数 94 int a[N_qsort],i; 95 for(i=N_qsort;i>0;i--) a[N_qsort-1]=i; 96 printf("排序运算中(对%d个数进行快速排序)\n",N_qsort);//采用最坏时间方案 97 clock_t start,end; 98 start=clock(); 99 Qsort(a,0,N_qsort-1);100 end=clock();101 double duration=(double)(end-start)/CLOCKS_PER_SEC;102 double score=(N_qsort*N_qsort)/duration;103 s_sort=score/10000;104 //printf("排序运算测试完毕!分数:%lf\n",s_sort);105 }106 void panduan(){107 float i=s_int+s_float+s_pi+s_sort;108 printf("根据分数,授予您的爱机<");109 if (i>0&&i<20000){110 printf("渣渣");111 }112 else if (i>20000&&i<30000){113 printf("低端");114 }115 else if (i>30000&&i<40000){116 printf("中端");117 }118 else if (i>40000&&i<50000){119 printf("高端");120 }121 else if (i>50000&&i<60000){122 printf("超高端");123 }124 else if (i>60000){125 printf("机皇");126 }127 printf(">称号\n");128 }129 void PAUSE(){130 printf("\n请按任意键继续...");getch();fflush(stdin);131 }

 

转载于:https://www.cnblogs.com/unixart/p/5965740.html

你可能感兴趣的文章
Spring MVC框架初步讲解
查看>>
关于dl dt dd 文字过长换行在移动端显示对齐的探讨总结
查看>>
C#线程安全打开/保存文件对话框
查看>>
201555334 实验一:Java开发环境的熟悉 总结
查看>>
docker系列 --- 命令详解
查看>>
观察者模式 -- 设计模式系列文章(二)
查看>>
MySql学习14-----数据备份和恢复
查看>>
页面小标签
查看>>
卷积分
查看>>
Asp.Net MVC Filter权限过滤使用说明
查看>>
一次群体code review
查看>>
python-虚拟环境搭建
查看>>
How does exercise keep your brain young?
查看>>
[Linux] 添加环境变量
查看>>
postgresql逻辑结构--表空间(四)
查看>>
rsync备份服务器搭建学习笔记
查看>>
Python中matplotlib模块解析
查看>>
ORA-14551: 无法在查询中执行 DML 操作 .
查看>>
数据结构--栈的应用(表达式求值 nyoj 35)
查看>>
注解:大话AOP与Android的爱恨情仇
查看>>