diff options
author | David Robillard <d@drobilla.net> | 2022-09-16 21:19:57 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-09-16 22:31:06 -0400 |
commit | 2e4d666eec1a372d4b64c527d6c4945ad98d2b58 (patch) | |
tree | a3a61d346c3d4e5b590b08db446d17307df0e3c5 /benchmark/bench_utils.hpp | |
parent | bf05ef949750cfca6e001b0f767cd2173441fc8c (diff) | |
download | chilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.tar.gz chilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.tar.bz2 chilbert-2e4d666eec1a372d4b64c527d6c4945ad98d2b58.zip |
Update clang-format configuration
Diffstat (limited to 'benchmark/bench_utils.hpp')
-rw-r--r-- | benchmark/bench_utils.hpp | 40 |
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 |