Last active
May 20, 2019 02:30
-
-
Save iaoedsz2008/346ad8fc2e0eab751e1b61094e0c9c58 to your computer and use it in GitHub Desktop.
c++跨平台高精度定时器
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <chrono> | |
int main() | |
{ | |
auto start = std::chrono::high_resolution_clock::now (); | |
/* | |
do something... | |
*/ | |
auto end = std::chrono::high_resolution_clock::now (); | |
auto duration = std::chrono::duration_cast<std::chrono::microseconds> (end - start); | |
printf ("总计耗时%f秒\n", (double(duration.count ()) * std::chrono::microseconds::period::num / std::chrono::microseconds::period::den)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment