Skip to content

Commit

Permalink
Some corrections and replacement of pragma once
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDonofrio committed Jan 30, 2021
1 parent 391f6ac commit d047ef2
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 241 deletions.
10 changes: 7 additions & 3 deletions bench/benchmark.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _BENCHMARK_HPP_
#define _BENCHMARK_HPP_

#include <chrono>
#include <iostream>
#include <vector>
Expand All @@ -10,9 +13,8 @@ using rep_t = double;
using elapsed_t = std::chrono::duration<rep_t, std::micro>;
using average_t = std::chrono::duration<rep_t, std::nano>;

// do_not_optimize works very well for gcc clang and msvc
// however there may be differences in overhead
// Other compilers do not have a do_not_optimize implementation
// do_not_optimize works very well for gcc and clang
// msvc works aswell, however results are not always accurate

#if __GNUC__ || __clang__
template<typename T>
Expand Down Expand Up @@ -52,3 +54,5 @@ inline void do_not_optimize(T const&)
auto __benchmark_iterations = __ITERATIONS * __OPERATIONS_PER_ITERATION; \
std::cout << "[ ELAPSED ] " << (__benchmark_elapsed.count() * 0.001) << " ms (" << __benchmark_iterations << " iterations)" << std::endl; \
std::cout << "[ AVERAGE ] " << (__benchmark_average.count() / __benchmark_iterations) << " ns" << std::endl;

#endif
Loading

0 comments on commit d047ef2

Please sign in to comment.