计录运行时间的方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计录运行时间的方法相关的知识,希望对你有一定的参考价值。

#include<stdio.h>
#incude<time.h>//计时的头文件 
clock_t start,stop;//clock_t 是clock()函数返回的变量类型 
double duration;
int main()
{
	start=clock();//开始计时
	MyFunction() ;//要测试运行时间的函数 
	stop=clock();//停止计时 
	duration=((double)(stop-start))/CLK_TCK;//运行时间duration,CLK_TCK为机器时钟每秒的时钟打点数 
	return 0;
}

 

以上是关于计录运行时间的方法的主要内容,如果未能解决你的问题,请参考以下文章