v0.3.0 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
18class Profiler {
19
20public:
21 // [Internal Types]
22
23 enum class Tag {
24 Frame,
25 EngineCpu,
26 RenderPrep,
27 RenderSubmit,
28 RenderGpu,
29 Present,
30 Physics,
31 Application
32 };
33
34 // [Internal Lifecycle Functions]
35
36 Profiler() = default;
37
38 Profiler(const Profiler&) = delete;
39 Profiler& operator=(const Profiler&) = delete;
40
41 Profiler(Profiler&&) = delete;
42 Profiler& operator=(Profiler&&) = delete;
43
44 // [Internal Member Functions]
45
46 void add(Tag tag, std::chrono::nanoseconds ns) noexcept;
47 void add(const std::string& key, std::chrono::nanoseconds ns) noexcept; // ! untested
48
49 // ! TEMPORARY !
50 // void subtract(Tag tag, std::chrono::nanoseconds ns); // ! untested
51 // void subtract(const std::string& key, std::chrono::nanoseconds ns); // ! untested
52
53 std::chrono::nanoseconds time(Tag tag);
54 std::chrono::nanoseconds time(const std::string& key); // ! untested
55
56 void reset();
57
58private:
59 // [Private Member Variables]
60
61 std::map<Tag, std::chrono::nanoseconds> _taggedSamples;
62 std::map<std::string, std::chrono::nanoseconds> _keyedSamples;
63};
64
65} // namespace a3d
66
67#endif // AVARA3D_PROFILE_PROFILER_H