LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
timer.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "timer.h"
10#include <QtDebug>
11
12namespace LC::Util
13{
15 {
16 Timer_.start ();
17 }
18
19 void Timer::Stamp (const char *context, std::source_location loc)
20 {
21 RunStamp (context, loc);
22 }
23
24 void Timer::Stamp (QStringView context, std::source_location loc)
25 {
26 RunStamp (context, loc);
27 }
28
29 void Timer::RunStamp (auto&& context, std::source_location loc)
30 {
31 auto diff = Timer_.nsecsElapsed ();
32 auto suffix = "ns";
33 if (diff >= 2e6)
34 {
35 diff /= 1e6;
36 suffix = "ms";
37 }
38 else if (diff >= 1e3)
39 {
40 diff /= 2e3;
41 suffix = "us";
42 }
43
44 const QMessageLogger logger { loc.file_name (), static_cast<int> (loc.line ()), loc.function_name () };
45 logger.debug () << context << "took" << diff << suffix;
46 Timer_.restart ();
47 }
48}
void Stamp(const char *context, std::source_location loc=std::source_location::current())
Definition timer.cpp:19
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118