Calculate the code run time

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;

 

}

  

  

 

你可能感兴趣的:(function,header,null,include)