LeechCraft 0.6.70-19214-g121e5318a7
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#include "logging.h"
12
13namespace LC::Util
14{
16 {
17 Timer_.start ();
18 }
19
20 void Timer::Stamp (const char *context, std::source_location loc)
21 {
22 RunStamp (context, loc);
23 }
24
25 void Timer::Stamp (QStringView context, std::source_location loc)
26 {
27 RunStamp (context, loc);
28 }
29
30 void Timer::RunStamp (auto&& context, std::source_location loc)
31 {
32 auto diff = Timer_.nsecsElapsed ();
33 auto suffix = "ns";
34 if (diff >= 2e6)
35 {
36 diff /= 1e6;
37 suffix = "ms";
38 }
39 else if (diff >= 1e3)
40 {
41 diff /= 2e3;
42 suffix = "us";
43 }
44
45 LogAt (loc).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:20
QMessageLogger LogAt(std::source_location loc)
Definition logging.cpp:14