Albert
Loading...
Searching...
No Matches
timeit.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2024 Manuel Schneider
2
3
#pragma once
4
#include <QDebug>
5
#include <QString>
6
#include <chrono>
7
#include <
albert/logging.h
>
8
9
// Private API
10
namespace
albert::experimental
11
{
12
13
struct
TimeIt
14
{
15
QString
name
;
16
std::chrono::system_clock::time_point
start
;
17
18
[[nodiscard]]
TimeIt
(
const
QString &
name
= {}):
19
name
(
name
),
20
start
(std::chrono::system_clock::now())
21
{}
22
23
~TimeIt
()
24
{
25
auto
end = std::chrono::system_clock::now();
26
auto
dur = std::chrono::duration_cast<std::chrono::microseconds>(end -
start
).count();
27
CRIT
<< QString(
ccyan
"%L1 µs | %2"
).arg(dur, 8).arg(
name
);
28
}
29
};
30
31
}
logging.h
CRIT
#define CRIT
Creates a log object (level critial) you can use to pipe text into (<<).
Definition
logging.h:23
ccyan
#define ccyan
Definition
logging.h:30
albert::experimental
Definition
timeit.h:11
albert::experimental::TimeIt
Definition
timeit.h:14
albert::experimental::TimeIt::TimeIt
TimeIt(const QString &name={})
Definition
timeit.h:18
albert::experimental::TimeIt::~TimeIt
~TimeIt()
Definition
timeit.h:23
albert::experimental::TimeIt::start
std::chrono::system_clock::time_point start
Definition
timeit.h:16
albert::experimental::TimeIt::name
QString name
Definition
timeit.h:15
workspace
albert
include
albert
timeit.h
Generated by
1.9.8