计算机百万亿次运算C程序

/******************************************************
文件名称:main.c
程序功能:计算机百万亿次运算C程序(main.c)
代码作者:chinayaosir QQ:44633197
测试工具:C + VC IDE / GCC compiler with windows xp
测试日期:01/03/2010
代码目录:
//1.导入头文件
//2.main主程序
修改历史:

*******************************************************/
//1.导入头文件
#include "stdio.h"
#include "time.h"
#include "runtime.h"
#define N 2000

//2.main主程序
int main(void){
    clock_t begin,end;
    begin=clock();   
    runtime(N);
    end=clock();
    printf("运行时间(毫秒):%d/n",(int)(end - begin));
    return 0;
}


/******************************************************
文件名称:runtime.h
程序功能:计算机百万亿次运算C程序(接口)
代码作者:chinayaosir QQ:44633197
blog网址:http://blog.csdn.net/chinayaosir
测试日期:01/01/2010
代码目录:
//1.runtime(int const times)函数使用说明
//2.runtime(int const times)函数接口定义
修改历史:
*******************************************************/
//1.runtime(int const times)函数使用说明
/*
runtime(int times)使用说明和作者电脑debug版本运行结果:
times与运行次数说明
times=200  表示    16亿次= 200 *  200 *  200 *  200   :运行时间(毫秒):15
times=400  表示   256亿次= 400 *  400 *  400 *  400   :运行时间(毫秒):234 
times=800  表示  4096亿次= 800 *  800 *  800 *  800   :运行时间(毫秒):1531
times=1000 表示   1万亿次=1000 * 1000 * 1000 * 1000   :运行时间(毫秒):2984
times=2000 表示  16万亿次=2000 * 2000 * 2000 * 2000   :运行时间(毫秒):23796
times=4000 表示 256万亿次=2000 * 2000 * 2000 * 2000   :运行时间(毫秒):153234
当N=2000,GUN/gcc版本改为release,优化:Maximize Speed,运行时间(毫秒):7828
当N=10000,vc++6.0版本改为release,优化:Maximize Speed,运行时间(毫秒):203
*/

//2.runtime(int const times)函数接口定义
extern void runtime(int const times);


/******************************************************
文件名称:runtime.c
程序功能:计算机百万亿次运算C程序(实现)
代码作者:chinayaosir QQ:44633197
blog网址:http://blog.csdn.net/chinayaosir
测试日期:01/01/2010
代码目录:
//1.导入头文件
//2.runtime()函数实现
    //2.1局部变量
    //2.2容错处理
    //2.3主循环代码
修改历史:

*******************************************************/
//1.导入头文件
#include "runtime.h"

//2.runtime()函数实现
void runtime(int const times){
    //2.1局部变量
    long i,j,k,n,max,count;
    //2.2容错处理
    if ( (times > 65535) || (times < 1 ))
        max=0;
    else
        max=times;       
    //2.3主循环代码
    count=0;
    for (i=0;i<max;i++)
        for (j=0;j<max;j++)
            for(k=0;k<max;k++)
                for(n=0;k<max;k++)
                    count++;
               
}

你可能感兴趣的:(c,Blog,测试,compiler,测试工具)