PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/chrono/timer.hpp

http://hadesmem.googlecode.com/
C++ Header | 62 lines | 37 code | 16 blank | 9 comment | 0 complexity | a2b24508292764848893694499ecb12a MD5 | raw file
 1//  boost/chrono/timer.hpp  ------------------------------------------------------------//
 2
 3//  Copyright Beman Dawes 2008
 4//  Copyright 2009 Vicente J. Botet Escriba
 5
 6//  Distributed under the Boost Software License, Version 1.0. (See accompanying
 7//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 8
 9//  See http://www.boost.org/libs/system for documentation.
10
11#ifndef BOOST_CHRONO_TIMER_HPP
12#define BOOST_CHRONO_TIMER_HPP
13
14#include <boost/chrono/chrono.hpp>
15#include <boost/system/error_code.hpp>
16
17namespace boost
18{
19  namespace chrono
20  {
21
22//--------------------------------------------------------------------------------------//
23//                                    timer                                             //
24//--------------------------------------------------------------------------------------//
25
26    template <class Clock=high_resolution_clock>
27    class timer
28    {
29    public:
30      typedef Clock                       clock;
31      typedef typename Clock::duration    duration;
32      typedef typename Clock::time_point  time_point;
33
34      explicit timer( system::error_code & ec = BOOST_CHRONO_THROWS )
35        { 
36          start(ec); 
37          }
38
39     ~timer() {}  // never throws
40
41      void start( system::error_code & ec = BOOST_CHRONO_THROWS )
42        { 
43          m_start = clock::now( ec ); 
44          }
45
46      duration elapsed( system::error_code & ec = BOOST_CHRONO_THROWS )
47        { return clock::now( ec ) - m_start; }
48
49    private:
50      time_point m_start;
51    };
52
53    typedef boost::chrono::timer< boost::chrono::system_clock > system_timer;
54#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
55    typedef boost::chrono::timer< boost::chrono::steady_clock > steady_timer;
56#endif
57    typedef boost::chrono::timer< boost::chrono::high_resolution_clock > high_resolution_timer;
58
59  } // namespace chrono
60} // namespace boost
61
62#endif