Calculate the code run time

来源:互联网 发布:帝国冲锋队 盔甲 淘宝 编辑:程序博客网 时间:2024/05/17 02:26

1. using the time() to calculate the code run time. This function is include in <time.h> header file.

2. Take the following test code as a reference.

 

------------------------------------------------------

#include <stdio.h>

#include <time.h>

 

main()

{

   time_t StartTime, EndTime;

   int RunTime;

 

   StartTime = time(NULL);

   .....

   .....

  
   EndTime = time(NULL);

 

   RunTime = StartTime - EndTime;

 

}