Created
November 21, 2015 01:41
-
-
Save alekswn/19354ee12a36b07215c8 to your computer and use it in GitHub Desktop.
Dawn easy benchmark for 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
#ifdef BENCH | |
#include <ctime> | |
#include <chrono> | |
#define BENCHMARK_START \ | |
auto t_start = std::chrono::high_resolution_clock::now(); \ | |
std::clock_t c_start = std::clock(); | |
#define BENCHMARK_FINISH( OUT_STREAM, NAME ) \ | |
std::clock_t c_end = std::clock(); \ | |
auto t_end = std::chrono::high_resolution_clock::now(); \ | |
OUT_STREAM << "BENCHMARK \"" << NAME << "\" : " \ | |
<< std::fixed << "CPU time: " \ | |
<< 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " ms; " \ | |
<< "Wall time: " \ | |
<< std::chrono::duration<double, std::milli>(t_end-t_start).count() \ | |
<< " ms\n"; | |
#else | |
#define BENCHMARK_START | |
#define BENCHMARK_FINISH( OUT_STREAM, NAME ) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment