Capturing a time in milliseconds

前端 未结 7 1120
一生所求
一生所求 2020-11-30 07:11

The following piece of code is used to print the time in the logs:

#define PRINTTIME() struct tm  * tmptime;
time_t     tmpGetTime;
time(&tmpGetTime);
tm         


        
7条回答
  •  我在风中等你
    2020-11-30 07:23

    You need a timer with a higher resolution in order to capture milliseconds. Try this:

    int cloc = clock();
    //do something that takes a few milliseconds
    cout << (clock() - cloc) << endl;
    

    This is of course dependent on your OS.

提交回复
热议问题