cpu测试

来源:互联网 发布:golang defer func 编辑:程序博客网 时间:2024/05/22 09:01

真的,刚开始就是想用这个程序来测一测cpu的性能,然而又被现实打脸,每次结果都不一样,QAQ。

#include<stdio.h>#include<stdlib.h>#include<time.h>int main(void){    clock_t start = 0,end = 0;    double cpu_time = 0;    start = clock();    int a = 0;    for(;a <= 100000;a++)        printf("\n%d",a);        printf("\nWe have finished.");    end = clock();    cpu_time = (double)(end - start) / CLOCKS_PER_SEC;    printf("\n%f seconds.\n",cpu_time);    system("pause");    return 0;  }
0 0
原创粉丝点击