Function name : clock
Header file: <time.h>
Function prototype : clock_t clock(void);
Function : Used to determine processor time
Parameters : no parameters
Return value : The time used by the processor clock since the program was started on success; -1 on failure
Program example : Get the time start and end of the processor clock, convert the time difference between the two clocks into seconds, and output the result*/
#include<time.h>#include<stdio.h>#include<windows.h>intmain(void){clock_tstart,end;//typedeflongclock_t;start=clock();//program Run to the current time Sleep(5000);//5 seconds interval end=clock();//The program runs to the current time printf(Thetimewas:%lfn,(end-start)*1.0/CLK_TCK);/ /CLK_TCK is 1000return0;}
Running results:
Thetimewas:5.000000