2 // Copyright Oliver Kowalke 2014.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
15 #include <boost/assert.hpp>
16 #include <boost/chrono.hpp>
17 #include <boost/cstdint.hpp>
19 typedef boost::chrono::high_resolution_clock clock_type;
20 typedef clock_type::duration duration_type;
21 typedef clock_type::time_point time_point_type;
25 boost::uint64_t operator()()
27 time_point_type start( clock_type::now() );
28 return ( clock_type::now() - start).count();
33 duration_type overhead_clock()
35 std::size_t iterations( 10);
36 std::vector< boost::uint64_t > overhead( iterations, 0);
37 for ( std::size_t i = 0; i < iterations; ++i)
39 overhead.begin(), overhead.end(),
41 BOOST_ASSERT( overhead.begin() != overhead.end() );
42 return duration_type( std::accumulate( overhead.begin(), overhead.end(), 0) / iterations);