Skip to content

Instantly share code, notes, and snippets.

@clarkzjw
Created May 6, 2017 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkzjw/6a929fc0acbdc1fbf5954cf82966b1ef to your computer and use it in GitHub Desktop.
Save clarkzjw/6a929fc0acbdc1fbf5954cf82966b1ef to your computer and use it in GitHub Desktop.
#include <iostream>
#include <chrono>
class TicToc
{
private:
typedef std::chrono::high_resolution_clock clock;
typedef std::chrono::microseconds res;
clock::time_point t1, t2;
public:
void tic()
{
t1 = clock::now();
}
void toc()
{
t2 = clock::now();
std::cout << "Elapsed time: "
<< std::chrono::duration_cast<res>(t2 - t1).count() / 1e6
<< " seconds." << std::endl;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment