Calculation of program execution time

Get the program execution time, don't talk nonsense, just go to the code.

 #include <stdio.h>  
 #include <process.h>  
 #include <time.h>
 
 int main(void)  
{
    
      
    float a = 3;  
    int i, begin, end;//定义开始和结束标志位  
  
    begin = clock();//开始计时  
    
    for(i = 1; i <= 1000000000; i++)
    {
    
      
        a += 1;  
    }
    
    end = clock();//结束计时
      
    printf("%d\r\n", end-begin);//差为时间,单位ms 
    
    return 0;
}  

Guess you like

Origin blog.csdn.net/u013318019/article/details/51760411