Last active
June 29, 2018 02:32
-
-
Save xylcbd/70a1bc19bfbdab2c2019423674f68b13 to your computer and use it in GitHub Desktop.
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
#include <chrono> | |
#include <string> | |
#include <iostream> | |
struct profiler | |
{ | |
std::string name; | |
std::chrono::high_resolution_clock::time_point p; | |
profiler(std::string const &n) : | |
name(n), p(std::chrono::high_resolution_clock::now()) { } | |
~profiler() | |
{ | |
using dura = std::chrono::duration<double>; | |
auto d = std::chrono::high_resolution_clock::now() - p; | |
std::cout << name << ": " | |
<< std::chrono::duration_cast<dura>(d).count() * 1000.0 << "ms" | |
<< std::endl; | |
} | |
}; | |
#define PROFILE_BLOCK(pbn) profiler _pfinstance(pbn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment