-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.h
47 lines (34 loc) · 1.24 KB
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by Saeid Yazdani on 10/3/2024.
//
#pragma once
#include <string>
#include <format>
#if defined(__DEBUG__) || defined(__BENCHMARK__)
constexpr std::string_view FORMAT_STRING = "| {:^10} | {:^40}() | {:<58} |";
#endif
#ifdef __DEBUG__
#define __PRINT_DEBUG__(text) \
puts(std::format(FORMAT_STRING, \
"DEBUG", __func__,(text)).c_str());
#else
#define __PRINT_DEBUG__(text)
#endif
#ifdef __BENCHMARK__
#include <embedonix/simplelibs/utilities/benchmark.h>
// Starts a timer by creating a time_point
#define __BENCHMARK_TIMER_START(MY_TIMER) \
std::chrono::time_point<std::chrono::high_resolution_clock> MY_TIMER; \
embedonix::simplelibs::utilities::benchmark::measure::start_timer(MY_TIMER);
// Stops a previously started time_point
#define __BENCHMARK_TIMER_STOP(MY_TIMER) \
puts(std::format(FORMAT_STRING, \
"BENCHMARK", __func__, \
embedonix::simplelibs::utilities::benchmark::measure::format_duration( \
embedonix::simplelibs::utilities::benchmark::measure::stop_timer(MY_TIMER)) \
).c_str() \
);
#else
#define __BENCHMARK_TIMER_START(timer)
#define __BENCHMARK_TIMER_STOP(timer)
#endif