Kea  1.9.9-git
stopwatch.cc
Go to the documentation of this file.
1 // Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 
9 #include <util/stopwatch.h>
10 #include <util/stopwatch_impl.h>
11 
12 namespace isc {
13 namespace util {
14 
15 using namespace boost::posix_time;
16 
17 Stopwatch::Stopwatch(const bool autostart)
18  : impl_(new StopwatchImpl()) {
19  // If the autostart has been specified, invoke start.
20  if (autostart) {
21  start();
22  }
23 }
24 
26  delete impl_;
27 }
28 
29 void
31  impl_->start();
32 }
33 
34 void
36  impl_->stop();
37 }
38 
39 void
41  impl_->reset();
42 }
43 
44 boost::posix_time::time_duration
46  return (impl_->getLastDuration());
47 }
48 
49 boost::posix_time::time_duration
51  return (impl_->getTotalDuration());
52 }
53 
54 long
56  return (getLastDuration().total_milliseconds());
57 }
58 
59 long
61  return (getTotalDuration().total_milliseconds());
62 }
63 
64 long
66  return (getLastDuration().total_microseconds());
67 }
68 
69 long
71  return (getTotalDuration().total_microseconds());
72 }
73 
74 std::string
77 }
78 
79 std::string
82 }
83 
84 } // end of isc::util
85 } // end of isc
void reset()
Resets the stopwatch.
Definition: stopwatch.cc:40
boost::posix_time::time_duration getTotalDuration() const
Retrieves total measured duration.
Definition: stopwatch.cc:50
boost::posix_time::time_duration getLastDuration() const
Retrieves the measured duration.
boost::posix_time::time_duration getTotalDuration() const
Retrieves the total measured duration.
~Stopwatch()
Destructor.
Definition: stopwatch.cc:25
void reset()
Reset the stopwatch.
long getTotalMicroseconds() const
Retrieves the total measured duration in microseconds.
Definition: stopwatch.cc:70
long getTotalMilliseconds() const
Retrieves the total measured duration in milliseconds.
Definition: stopwatch.cc:60
void stop()
Stop the stopwatch.
boost::posix_time::time_duration getLastDuration() const
Retrieves last measured duration.
Definition: stopwatch.cc:45
Stopwatch class implementation.
void stop()
Stops the stopwatch.
Definition: stopwatch.cc:35
long getLastMicroseconds() const
Retrieves the last measured duration in microseconds.
Definition: stopwatch.cc:65
std::string logFormatLastDuration() const
Returns the last measured duration in the format directly usable in log messages. ...
Definition: stopwatch.cc:75
void start()
Starts the stopwatch.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static std::string logFormat(const boost::posix_time::time_duration &duration)
Returns the duration in the textual format which can be directly used in log messages.
long getLastMilliseconds() const
Retrieves the last measured duration in milliseconds.
Definition: stopwatch.cc:55
std::string logFormatTotalDuration() const
Returns the total measured duration in the format directly usable in the log messages.
Definition: stopwatch.cc:80
Stopwatch(const bool autostart=true)
Constructor.
Definition: stopwatch.cc:17
void start()
Starts the stopwatch.
Definition: stopwatch.cc:30