Easily measure elapsed time

前端 未结 26 2046
栀梦
栀梦 2020-11-22 04:13

I am trying to use time() to measure various points of my program.

What I don\'t understand is why the values in the before and after are the same? I understand thi

26条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 04:56

    #include // for clock
    #include // for fmod
    #include //for system
    #include  //for delay
    
    using namespace std;
    
    int main()
    {
    
    
       clock_t t1,t2;
    
       t1=clock(); // first time capture
    
       // Now your time spanning loop or code goes here
       // i am first trying to display time elapsed every time loop runs
    
       int ddays=0; // d prefix is just to say that this variable will be used for display
       int dhh=0;
       int dmm=0;
       int dss=0;
    
       int loopcount = 1000 ; // just for demo your loop will be different of course
    
       for(float count=1;count

提交回复
热议问题