libhatchet
Loading...
Searching...
No Matches
hxprofiler.hpp
Go to the documentation of this file.
1#pragma once
2// SPDX-FileCopyrightText: © 2017-2026 Adrian Johnston.
3// SPDX-License-Identifier: MIT
4// This file is licensed under the MIT license found in the LICENSE.md file.
5
20
21#include "libhatchet.h"
22#if !(HX_USE_MACROS_WITH_MODULE)
23
24// These are always included so the build doesn't break when the profiler is
25// turned off.
26#include "hxvector.hpp"
27#include "hxthread.hpp"
28
29HX_NS_BEGIN_
30
35using hxcycles_t = size_t;
36
41
45
49
53
54HX_NS_END_
55
56#endif // !HX_USE_MACROS_WITH_MODULE
57
62#define hxprofile_scope(label_string_literal_) \
63 HX_PROFILE_ONLY_(const HX_NS_PREFIX_ hxdetail_::hxprofiler_scope_internal_<> \
64 HX_APPEND_COUNTER(hxprofile_scope_)(label_string_literal_))
65
73#define hxprofile_scope_min(label_string_literal_, min_cycles_) \
74 HX_PROFILE_ONLY_(const HX_NS_PREFIX_ hxdetail_::hxprofiler_scope_internal_<min_cycles_> \
75 HX_APPEND_COUNTER(hxprofile_scope_)(label_string_literal_))
76
79#define hxprofiler_start() HX_PROFILE_ONLY_(HX_NS_PREFIX_ hxdetail_::hxg_profiler_.start_())
80
83#define hxprofiler_stop() HX_PROFILE_ONLY_(HX_NS_PREFIX_ hxdetail_::hxg_profiler_.stop_())
84
87#define hxprofiler_log() HX_PROFILE_ONLY_(HX_NS_PREFIX_ hxdetail_::hxg_profiler_.log_())
88
89#if HX_USE_FILE_IO
94#define hxprofiler_write_to_chrome_tracing(filename_) \
95 HX_PROFILE_ONLY_(HX_NS_PREFIX_ hxdetail_::hxg_profiler_.write_to_chrome_tracing_(filename_))
96#endif
97#include "detail/hxprofiler_detail.hpp"
constexpr double hxmicroseconds_per_cycle
hxmicroseconds_per_cycle - The number of microseconds in a single processor cycle,...
Definition hxprofiler.hpp:48
constexpr double hxmilliseconds_per_cycle
hxmilliseconds_per_cycle - The number of milliseconds in a single processor cycle,...
Definition hxprofiler.hpp:44
hxcycles_t hxtime_sample_cycles(void)
hxtime_sample_cycles(void) - Set up the processor cycle counter for your architecture.
constexpr double hxcycles_per_second
hxcycles_per_second - WARNING: Customize for your processor speed.
Definition hxprofiler.hpp:40
size_t hxcycles_t
hxcycles_t - Stores approximately 1.5 seconds to 209 years worth of processor cycles starting from an...
Definition hxprofiler.hpp:35
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:120
#define hxinline_constexpr
hxinline_constexpr - Enables C++17 compatable "inline constexpr" usage for variables so they can be e...
Definition hxsettings.h:272
#define HX_CYCLES_PER_SECOND
HX_CYCLES_PER_SECOND - Configures the CPU cycles per second.
Definition hxsettings.h:327
C++ wrappers for POSIX pthreads or C11 threads.h.
Implements std::vector, std::inplace_vector and std::back_insert_iterator with a few things added and...
Provides core macros, memory management and feature detection.