Kea: stopwatch.h Source File

| Kea 3.2.0-git

stopwatch.h
Go to the documentation of this file.
1// Copyright (C) 2015-2024 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#ifndef STOPWATCH_H
8#define STOPWATCH_H
9
10#include <boost/noncopyable.hpp>
11#include <boost/date_time/posix_time/posix_time.hpp>
12
13namespace isc {
14namespace util {
15
17class StopwatchImpl;
18
35 class Stopwatch : boost::noncopyable {
36public:
37
45 Stopwatch(const bool autostart = true);
46
50 ~Stopwatch();
51
59 void start();
60
71 void stop();
72
78 void reset();
79
86 boost::posix_time::time_duration getLastDuration() const;
87
96 boost::posix_time::time_duration getTotalDuration() const;
97
99 long getLastMilliseconds() const;
100
102 long getTotalMilliseconds() const;
103
105 long getLastMicroseconds() const;
106
108 long getTotalMicroseconds() const;
109
112 std::string logFormatLastDuration() const;
113
116 std::string logFormatTotalDuration() const;
117
118private:
119
121 boost::shared_ptr<StopwatchImpl> impl_;
122
123};
124
125}
126}
127
128#endif // STOPWATCH_H
129
isc::util::StopwatchImpl
Stopwatch class implementation.
Definition stopwatch_impl.h:28
isc::util::Stopwatch::getLastMilliseconds
long getLastMilliseconds() const
Retrieves the last measured duration in milliseconds.
Definition stopwatch.cc:54
isc::util::Stopwatch::getLastMicroseconds
long getLastMicroseconds() const
Retrieves the last measured duration in microseconds.
Definition stopwatch.cc:64
isc::util::Stopwatch::getTotalMilliseconds
long getTotalMilliseconds() const
Retrieves the total measured duration in milliseconds.
Definition stopwatch.cc:59
isc::util::Stopwatch::Stopwatch
Stopwatch(const bool autostart=true)
Constructor.
Definition stopwatch.cc:17
isc::util::Stopwatch::stop
void stop()
Stops the stopwatch.
Definition stopwatch.cc:34
isc::util::Stopwatch::~Stopwatch
~Stopwatch()
Destructor.
Definition stopwatch.cc:25
isc::util::Stopwatch::getTotalMicroseconds
long getTotalMicroseconds() const
Retrieves the total measured duration in microseconds.
Definition stopwatch.cc:69
isc::util::Stopwatch::getLastDuration
boost::posix_time::time_duration getLastDuration() const
Retrieves last measured duration.
Definition stopwatch.cc:44
isc::util::Stopwatch::start
void start()
Starts the stopwatch.
Definition stopwatch.cc:29
isc::util::Stopwatch::logFormatTotalDuration
std::string logFormatTotalDuration() const
Returns the total measured duration in the format directly usable in the log messages.
Definition stopwatch.cc:79
isc::util::Stopwatch::reset
void reset()
Resets the stopwatch.
Definition stopwatch.cc:39
isc::util::Stopwatch::logFormatLastDuration
std::string logFormatLastDuration() const
Returns the last measured duration in the format directly usable in log messages.
Definition stopwatch.cc:74
isc::util::Stopwatch::getTotalDuration
boost::posix_time::time_duration getTotalDuration() const
Retrieves total measured duration.
Definition stopwatch.cc:49
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18