]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/Stopwatch.cc
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "base/Stopwatch.h"
11 #include "debug/Stream.h"
13 static_assert(Stopwatch::Clock::is_steady
,
14 "Stopwatch::Clock is suitable for measuring real-time intervals");
16 Stopwatch::Stopwatch():
17 subtotal_(Clock::duration::zero())
21 Stopwatch::Clock::duration
22 Stopwatch::total() const
24 auto result
= subtotal_
;
26 result
+= Clock::now() - runStart_
;
34 runStart_
= Clock::now();
35 debugs(1, 7, "period " << resumes_
<< " started after " << subtotal_
.count());
40 /// ends the current measurement period if needed; requires prior resume()
41 void Stopwatch::pause()
45 const auto runtime
= Clock::now() - runStart_
;
47 debugs(1, 7, "period " << resumes_
<< " ran for " << runtime
.count());