1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 #ifndef BOOST_HANA_BENCHMARK_MEASURE_HPP
6 #define BOOST_HANA_BENCHMARK_MEASURE_HPP
12 namespace boost { namespace hana { namespace benchmark {
13 auto measure = [](auto f) {
14 constexpr auto repetitions = 500ull;
15 auto start = std::chrono::steady_clock::now();
16 for (auto i = repetitions; i > 0; --i) {
19 auto stop = std::chrono::steady_clock::now();
21 auto time = std::chrono::duration_cast<std::chrono::duration<float>>(
22 (stop - start) / repetitions
24 std::cout << std::fixed;
25 std::cout << "[execution time: " << time.count() << "]" << std::endl;