• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  boost auto_timers_construction.cpp  ------------------------------------------------//
2 
3 //  Copyright Beman Dawes 2007, 2011
4 
5 //  Distributed under the Boost Software License, Version 1.0.
6 //  See http://www.boost.org/LICENSE_1_0.txt)
7 
8 //  See http://www.boost.org/libs/timer for documentation.
9 
10 //--------------------------------------------------------------------------------------//
11 
12 //  These constructors are in a separate file so that this translation unit will
13 //  not be linked in except when one of the constructors is actually used. This
14 //  is important since header <iostream> is required, and it incurs the cost of
15 //  the standard stream objects even if they are not used.
16 
17 //--------------------------------------------------------------------------------------//
18 
19 // define BOOST_TIMER_SOURCE so that <boost/timer/config.hpp> knows
20 // the library is being built (possibly exporting rather than importing code)
21 #define BOOST_TIMER_SOURCE
22 
23 #include <boost/timer/timer.hpp>
24 #include <iostream>
25 
26 namespace
27 {
28   // CAUTION: must be identical to same constant in cpu_timer.cpp
29   const std::string default_fmt(" %ws wall, %us user + %ss system = %ts CPU (%p%)\n");
30 }
31 
32 namespace boost
33 {
34   namespace timer
35   {
auto_cpu_timer(short places)36     auto_cpu_timer::auto_cpu_timer(short places)                                  // #1
37       : m_places(places), m_os(&std::cout), m_format(default_fmt) { start(); }
38 
auto_cpu_timer(short places,const std::string & format)39     auto_cpu_timer::auto_cpu_timer(short places, const std::string& format)       // #2
40       : m_places(places), m_os(&std::cout), m_format(format) { start(); }
41 
auto_cpu_timer(const std::string & format)42     auto_cpu_timer::auto_cpu_timer(const std::string& format)                     // #3
43       : m_places(default_places), m_os(&std::cout), m_format(format) { start(); }
44 
45   } // namespace timer
46 } // namespace boost
47