|
|
|||
Warning, file /include/boost/timer.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // boost timer.hpp header file ---------------------------------------------// 0002 0003 // Copyright Beman Dawes 1994-99. Distributed under the Boost 0004 // Software License, Version 1.0. (See accompanying file 0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 0007 // See http://www.boost.org/libs/timer for documentation. 0008 0009 // Revision History 0010 // 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock) 0011 // 12 Jan 01 Change to inline implementation to allow use without library 0012 // builds. See docs for more rationale. (Beman Dawes) 0013 // 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock) 0014 // 16 Jul 99 Second beta 0015 // 6 Jul 99 Initial boost version 0016 0017 #ifndef BOOST_TIMER_HPP 0018 #define BOOST_TIMER_HPP 0019 0020 #if !defined(BOOST_TIMER_ENABLE_DEPRECATED) 0021 # error This header is deprecated and will be removed. (You can define BOOST_TIMER_ENABLE_DEPRECATED to suppress this error.) 0022 #endif 0023 0024 #include <boost/config/header_deprecated.hpp> 0025 BOOST_HEADER_DEPRECATED( "the facilities in <boost/timer/timer.hpp>" ) 0026 0027 #include <boost/config.hpp> 0028 #include <ctime> 0029 #include <boost/limits.hpp> 0030 0031 # ifdef BOOST_NO_STDC_NAMESPACE 0032 namespace std { using ::clock_t; using ::clock; } 0033 # endif 0034 0035 0036 namespace boost { 0037 0038 // timer -------------------------------------------------------------------// 0039 0040 // A timer object measures elapsed time. 0041 0042 // It is recommended that implementations measure wall clock rather than CPU 0043 // time since the intended use is performance measurement on systems where 0044 // total elapsed time is more important than just process or CPU time. 0045 0046 // Warnings: The maximum measurable elapsed time may well be only 596.5+ hours 0047 // due to implementation limitations. The accuracy of timings depends on the 0048 // accuracy of timing information provided by the underlying platform, and 0049 // this varies a great deal from platform to platform. 0050 0051 class timer 0052 { 0053 public: 0054 timer() { _start_time = std::clock(); } // postcondition: elapsed()==0 0055 // timer( const timer& src ); // post: elapsed()==src.elapsed() 0056 // ~timer(){} 0057 // timer& operator=( const timer& src ); // post: elapsed()==src.elapsed() 0058 void restart() { _start_time = std::clock(); } // post: elapsed()==0 0059 double elapsed() const // return elapsed time in seconds 0060 { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; } 0061 0062 double elapsed_max() const // return estimated maximum value for elapsed() 0063 // Portability warning: elapsed_max() may return too high a value on systems 0064 // where std::clock_t overflows or resets at surprising values. 0065 { 0066 return (double((std::numeric_limits<std::clock_t>::max)()) 0067 - double(_start_time)) / double(CLOCKS_PER_SEC); 0068 } 0069 0070 double elapsed_min() const // return minimum value for elapsed() 0071 { return double(1)/double(CLOCKS_PER_SEC); } 0072 0073 private: 0074 std::clock_t _start_time; 0075 }; // timer 0076 0077 } // namespace boost 0078 0079 #endif // BOOST_TIMER_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|