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
11
struct
TimeIt
12
{
13
QString
name
;
14
std::chrono::system_clock::time_point
start
;
15
16
[[nodiscard]]
TimeIt
(
const
QString &
name
= {}):
17
name
(
name
),
18
start
(std::chrono::system_clock::now())
19
{}
20
21
~TimeIt
()
22
{
23
auto
end = std::chrono::system_clock::now();
24
auto
dur = std::chrono::duration_cast<std::chrono::microseconds>(end -
start
).count();
25
CRIT
<< QString(
ccyan
"%L1 µs | %2"
).arg(dur, 8).arg(
name
);
26
}
27
};
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
TimeIt
Definition
timeit.h:12
TimeIt::name
QString name
Definition
timeit.h:13
TimeIt::start
std::chrono::system_clock::time_point start
Definition
timeit.h:14
TimeIt::~TimeIt
~TimeIt()
Definition
timeit.h:21
TimeIt::TimeIt
TimeIt(const QString &name={})
Definition
timeit.h:16
workspace
albert
include
albert
timeit.h
Generated by
1.9.8