Avara3D 0.2.0
C++ API reference
Profiler.h
1//
2// Profiler.h
3// avara3d
4//
5// Created by Morgan Davis on 12/6/25.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_PROFILE_PROFILER_H
10#define AVARA3D_PROFILE_PROFILER_H
11
12#include <chrono>
13#include <map>
14#include <string>
15
16namespace a3d {
17
18 class Profiler {
19
20 public:
21 // [Internal Types]
22
23 enum class Tag {
24 Frame,
25 EngineCpu,
26 RenderCpu,
27 RenderGpu,
28 Physics,
29 Application
30 };
31
32 // [Internal Lifecycle Functions]
33
34 Profiler() = default;
35
36 Profiler(const Profiler&) = delete;
37 Profiler& operator=(const Profiler&) = delete;
38
39 Profiler(Profiler&&) = delete;
40 Profiler& operator=(Profiler&&) = delete;
41
42 // [Internal Member Functions]
43
44 void add(Tag tag, std::chrono::nanoseconds ns) noexcept;
45 void add(const std::string& key, std::chrono::nanoseconds ns) noexcept; // ! untested
46
47 // ! TEMPORARY !
48// void subtract(Tag tag, std::chrono::nanoseconds ns); // ! untested
49// void subtract(const std::string& key, std::chrono::nanoseconds ns); // ! untested
50
51 std::chrono::nanoseconds time(Tag tag);
52 std::chrono::nanoseconds time(const std::string& key); // ! untested
53
54 void reset();
55
56 private:
57 // [Private Member Variables]
58
59 std::map<Tag, std::chrono::nanoseconds> _taggedSamples;
60 std::map<std::string, std::chrono::nanoseconds> _keyedSamples;
61 };
62
63}
64
65#endif // AVARA3D_PROFILE_PROFILER_H