aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark/bench_utils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/bench_utils.hpp')
-rw-r--r--benchmark/bench_utils.hpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/benchmark/bench_utils.hpp b/benchmark/bench_utils.hpp
index a3f7f81..620cb27 100644
--- a/benchmark/bench_utils.hpp
+++ b/benchmark/bench_utils.hpp
@@ -28,37 +28,37 @@
using Duration = std::chrono::duration<double, std::micro>;
/// Write a TSV row to `os` with `n` as the first column followed by `results`
-template <class T, size_t M>
+template<class T, size_t M>
void
write_row(std::ostream& os, const size_t n, const std::array<T, M>& results)
{
- os << n;
- for (const auto t : results) {
- if (t == Duration::zero()) {
- os << "\tNaN";
- } else {
- os << '\t' << t.count();
- }
- }
- os << std::endl;
+ os << n;
+ for (const auto t : results) {
+ if (t == Duration::zero()) {
+ os << "\tNaN";
+ } else {
+ os << '\t' << t.count();
+ }
+ }
+ os << std::endl;
}
/// Repeatedly run an operation and return the average time
-template <class Operation>
+template<class Operation>
Duration
run_bench(const Operation& op)
{
- static constexpr auto bench_duration = std::chrono::milliseconds{10};
+ static constexpr auto bench_duration = std::chrono::milliseconds{10};
- const auto t_start = std::chrono::steady_clock{}.now();
- auto t_now = t_start;
- size_t count = 0;
- for (; t_now < t_start + bench_duration; ++count) {
- op(count);
- t_now = std::chrono::steady_clock{}.now();
- }
+ const auto t_start = std::chrono::steady_clock{}.now();
+ auto t_now = t_start;
+ size_t count = 0;
+ for (; t_now < t_start + bench_duration; ++count) {
+ op(count);
+ t_now = std::chrono::steady_clock{}.now();
+ }
- return (t_now - t_start) / count;
+ return (t_now - t_start) / count;
}
#endif