HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
telemetry
trace.hpp
1
// Copyright Take Vos 2019, 2021.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
#pragma once
6
7
#include "../utility/utility.hpp"
8
#include "../time/time.hpp"
9
#include "
counters.hpp
"
10
#include "../macros.hpp"
11
#include <array>
12
#include <tuple>
13
#include <exception>
14
15
hi_export_module(hikogui.telemetry : trace);
16
17
hi_export
namespace
hi::inline
v1
{
18
19
class
trace_base
{
20
public
:
21
trace_base
(
trace_base
const
&) =
delete
;
22
trace_base
(
trace_base
&&) =
delete
;
23
trace_base
&operator=(
trace_base
const
&) =
delete
;
24
trace_base
&operator=(
trace_base
&&) =
delete
;
25
26
trace_base
() noexcept : _time_stamp(
time_stamp_count::inplace
{}), _next(std::exchange(_top,
this
)) {}
27
28
virtual
~trace_base
()
29
{
30
_top = _next;
31
}
32
33
virtual
void
log()
const
noexcept
= 0;
34
35
protected
:
36
inline
static
thread_local
trace_base
*_top =
nullptr
;
37
38
time_stamp_count
_time_stamp;
39
trace_base
*_next =
nullptr
;
40
};
41
42
template
<fixed_
string
Tag>
43
class
trace
:
public
trace_base
{
44
public
:
45
trace
() noexcept :
trace_base
() {}
46
47
virtual
~trace
()
noexcept
48
{
49
if
(std::uncaught_exceptions()) {
50
log();
51
}
52
53
auto
const
current_time_stamp =
time_stamp_count
{
time_stamp_count::inplace
{}};
54
global_counter<Tag>.add_duration(current_time_stamp.count() - _time_stamp.count());
55
}
56
57
void
log()
const
noexcept
override
58
{
59
if
(_next) {
60
_next->log();
61
}
62
}
63
};
64
65
66
}
// namespace hi::inline v1
counters.hpp
v1
DOXYGEN BUG.
Definition
algorithm_misc.hpp:20
v1::trace_base
Definition
trace.hpp:19
v1::trace
Definition
trace.hpp:43
v1::time_stamp_count
Since Window's 10 QueryPerformanceCounter() counts at only 10MHz which is too low to measure performa...
Definition
time_stamp_count.hpp:36
v1::time_stamp_count::inplace
Definition
time_stamp_count.hpp:38
Generated on Mon Apr 22 2024 12:51:37 for HikoGUI by
1.10.0