annotate DEPENDENCIES/generic/include/boost/timer.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // boost timer.hpp header file ---------------------------------------------//
Chris@16 2
Chris@16 3 // Copyright Beman Dawes 1994-99. Distributed under the Boost
Chris@16 4 // Software License, Version 1.0. (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 // See http://www.boost.org/libs/timer for documentation.
Chris@16 8
Chris@16 9 // Revision History
Chris@16 10 // 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock)
Chris@16 11 // 12 Jan 01 Change to inline implementation to allow use without library
Chris@16 12 // builds. See docs for more rationale. (Beman Dawes)
Chris@16 13 // 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock)
Chris@16 14 // 16 Jul 99 Second beta
Chris@16 15 // 6 Jul 99 Initial boost version
Chris@16 16
Chris@16 17 #ifndef BOOST_TIMER_HPP
Chris@16 18 #define BOOST_TIMER_HPP
Chris@16 19
Chris@16 20 #include <boost/config.hpp>
Chris@16 21 #include <ctime>
Chris@16 22 #include <boost/limits.hpp>
Chris@16 23
Chris@16 24 # ifdef BOOST_NO_STDC_NAMESPACE
Chris@16 25 namespace std { using ::clock_t; using ::clock; }
Chris@16 26 # endif
Chris@16 27
Chris@16 28
Chris@16 29 namespace boost {
Chris@16 30
Chris@16 31 // timer -------------------------------------------------------------------//
Chris@16 32
Chris@16 33 // A timer object measures elapsed time.
Chris@16 34
Chris@16 35 // It is recommended that implementations measure wall clock rather than CPU
Chris@16 36 // time since the intended use is performance measurement on systems where
Chris@16 37 // total elapsed time is more important than just process or CPU time.
Chris@16 38
Chris@16 39 // Warnings: The maximum measurable elapsed time may well be only 596.5+ hours
Chris@16 40 // due to implementation limitations. The accuracy of timings depends on the
Chris@16 41 // accuracy of timing information provided by the underlying platform, and
Chris@16 42 // this varies a great deal from platform to platform.
Chris@16 43
Chris@16 44 class timer
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 timer() { _start_time = std::clock(); } // postcondition: elapsed()==0
Chris@16 48 // timer( const timer& src ); // post: elapsed()==src.elapsed()
Chris@16 49 // ~timer(){}
Chris@16 50 // timer& operator=( const timer& src ); // post: elapsed()==src.elapsed()
Chris@16 51 void restart() { _start_time = std::clock(); } // post: elapsed()==0
Chris@16 52 double elapsed() const // return elapsed time in seconds
Chris@16 53 { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; }
Chris@16 54
Chris@16 55 double elapsed_max() const // return estimated maximum value for elapsed()
Chris@16 56 // Portability warning: elapsed_max() may return too high a value on systems
Chris@16 57 // where std::clock_t overflows or resets at surprising values.
Chris@16 58 {
Chris@16 59 return (double((std::numeric_limits<std::clock_t>::max)())
Chris@16 60 - double(_start_time)) / double(CLOCKS_PER_SEC);
Chris@16 61 }
Chris@16 62
Chris@16 63 double elapsed_min() const // return minimum value for elapsed()
Chris@16 64 { return double(1)/double(CLOCKS_PER_SEC); }
Chris@16 65
Chris@16 66 private:
Chris@16 67 std::clock_t _start_time;
Chris@16 68 }; // timer
Chris@16 69
Chris@16 70 } // namespace boost
Chris@16 71
Chris@16 72 #endif // BOOST_TIMER_HPP