Easily measure elapsed time

前端 未结 26 2613
栀梦
栀梦 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 05:09

    The time(NULL) function call will return the number of seconds elapsed since epoc: January 1 1970. Perhaps what you mean to do is take the difference between two timestamps:

    size_t start = time(NULL);
    doSomthing();
    doSomthingLong();
    
    printf ("**MyProgram::time elapsed= %lds\n", time(NULL) - start);
    

提交回复
热议问题