Kea: stopwatch_impl.h Source File

| Kea 3.2.0-git

stopwatch_impl.h
Go to the documentation of this file.
1// Copyright (C) 2015-2023 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_IMPL_H
8#define STOPWATCH_IMPL_H
9
10#include <boost/date_time/posix_time/posix_time.hpp>
11#include <boost/scoped_ptr.hpp>
12
13namespace isc {
14namespace util {
15
28 class StopwatchImpl {
29public:
30
35 StopwatchImpl();
36
41 virtual ~StopwatchImpl();
42
50 void start();
51
60 void stop();
61
65 void reset();
66
70 boost::posix_time::time_duration getLastDuration() const;
71
75 boost::posix_time::time_duration getTotalDuration() const;
76
83 static std::string
84 logFormat(const boost::posix_time::time_duration& duration);
85
86protected:
87
99 virtual boost::posix_time::ptime getCurrentTime() const;
100
101private:
102
104 bool started_;
105
107 boost::posix_time::ptime last_start_;
108
110 boost::posix_time::ptime last_stop_;
111
114 boost::posix_time::time_duration cumulative_time_;
115
116};
117
118}
119}
120
121#endif // STOPWATCH_H
122
isc::util::StopwatchImpl::start
void start()
Starts the stopwatch.
Definition stopwatch_impl.cc:29
isc::util::StopwatchImpl::~StopwatchImpl
virtual ~StopwatchImpl()
Virtual destructor.
Definition stopwatch_impl.cc:25
isc::util::StopwatchImpl::getTotalDuration
boost::posix_time::time_duration getTotalDuration() const
Retrieves the total measured duration.
Definition stopwatch_impl.cc:70
isc::util::StopwatchImpl::logFormat
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.
Definition stopwatch_impl.cc:82
isc::util::StopwatchImpl::StopwatchImpl
StopwatchImpl()
Constructor.
Definition stopwatch_impl.cc:18
isc::util::StopwatchImpl::reset
void reset()
Reset the stopwatch.
Definition stopwatch_impl.cc:49
isc::util::StopwatchImpl::getCurrentTime
virtual boost::posix_time::ptime getCurrentTime() const
Returns the current time.
Definition stopwatch_impl.cc:97
isc::util::StopwatchImpl::stop
void stop()
Stop the stopwatch.
Definition stopwatch_impl.cc:38
isc::util::StopwatchImpl::getLastDuration
boost::posix_time::time_duration getLastDuration() const
Retrieves the measured duration.
Definition stopwatch_impl.cc:61
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