// Copyright 2010 Vicente J. Botet Escriba // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt #ifndef BOOST_CHRONO_TEST_CYCLE_COUNT_HPP #define BOOST_CHRONO_TEST_CYCLE_COUNT_HPP #include #include #include #include #include #include namespace ex { template struct cycle_count { typedef typename boost::ratio_multiply, boost::mega>::type frequency; // Mhz typedef typename boost::ratio_divide, frequency>::type period; typedef long long rep; typedef boost::chrono::duration duration; typedef boost::chrono::time_point time_point; BOOST_STATIC_CONSTEXPR bool is_steady = true; static long long ticks_; static time_point now() { // return exact cycle count return time_point(duration(ticks_)); } static time_point now(boost::system::error_code & ) { // return exact cycle count return time_point(duration(ticks_)); } static void advance(std::size_t ticks) { ticks_ += ticks; } template static void advance(D const& d) { ticks_ += boost::chrono::ceil(d).count(); } }; template long long cycle_count::ticks_ = 0; template void sleep_for(const boost::chrono::duration& d) { Clock::advance(d); } } namespace boost { namespace chrono { template struct basic_stopwatch_reporter_default_formatter > > { typedef basic_elapsed_formatter type; }; // template // struct wstopwatch_reporter_default_formatter > > // { // typedef welapsed_formatter type; // }; } // namespace chrono } // namespace boost #endif