123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- #ifndef BOOST_TIMER_TIMER_HPP
- #define BOOST_TIMER_TIMER_HPP
- #include <boost/timer/config.hpp>
- #include <boost/cstdint.hpp>
- #include <string>
- #include <cstring>
- #include <ostream>
- #include <boost/config/abi_prefix.hpp> // must be the last #include
- # if defined(_MSC_VER)
- # pragma warning(push)
- # pragma warning(disable : 4251)
- # endif
- namespace boost
- {
- namespace timer
- {
- class cpu_timer;
- class auto_cpu_timer;
- typedef boost::int_least64_t nanosecond_type;
- struct cpu_times
- {
- nanosecond_type wall;
- nanosecond_type user;
- nanosecond_type system;
- void clear() { wall = user = system = 0; }
- };
-
- const short default_places = 6;
- BOOST_TIMER_DECL
- std::string format(const cpu_times& times, short places, const std::string& format);
- BOOST_TIMER_DECL
- std::string format(const cpu_times& times, short places = default_places);
- class BOOST_TIMER_DECL cpu_timer
- {
- public:
-
- cpu_timer() BOOST_NOEXCEPT { start(); }
-
- bool is_stopped() const BOOST_NOEXCEPT { return m_is_stopped; }
- cpu_times elapsed() const BOOST_NOEXCEPT;
- std::string format(short places, const std::string& format) const
- { return ::boost::timer::format(elapsed(), places, format); }
- std::string format(short places = default_places) const
- { return ::boost::timer::format(elapsed(), places); }
-
- void start() BOOST_NOEXCEPT;
- void stop() BOOST_NOEXCEPT;
- void resume() BOOST_NOEXCEPT;
- private:
- cpu_times m_times;
- bool m_is_stopped;
- };
- class BOOST_TIMER_DECL auto_cpu_timer : public cpu_timer
- {
- public:
-
-
-
-
- explicit auto_cpu_timer(short places = default_places);
- auto_cpu_timer(short places, const std::string& format);
- explicit auto_cpu_timer(const std::string& format);
- auto_cpu_timer(std::ostream& os, short places,
- const std::string& format)
- : m_places(places), m_os(&os), m_format(format)
- { start(); }
- explicit auto_cpu_timer(std::ostream& os, short places = default_places);
- auto_cpu_timer(std::ostream& os, const std::string& format)
- : m_places(default_places), m_os(&os), m_format(format)
- { start(); }
- ~auto_cpu_timer();
-
-
-
-
- std::ostream& ostream() const { return *m_os; }
- short places() const { return m_places; }
- const std::string& format_string() const { return m_format; }
-
- void report();
- private:
- short m_places;
- std::ostream* m_os;
- std::string m_format;
- };
-
- }
- }
- # if defined(_MSC_VER)
- # pragma warning(pop)
- # endif
- #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
- #endif
|