Last active
October 21, 2017 17:27
-
-
Save dnbaker/d23a443c000cc6511a52f663af2e92d1 to your computer and use it in GitHub Desktop.
Code Timing Macro (C++)
This file contains hidden or 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
// You must have #included <chrono> and <cstdio> | |
#define TIME_CODE(code, name) do \ | |
{ \ | |
using namespace std::chrono; \ | |
const auto i(system_clock::now()); \ | |
{ code } \ | |
const auto j(system_clock::now()); \ | |
std::fprintf(stderr, "Task %s took %lfs\n", name, duration<double>(j - i).count());\ | |
} while(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment