Unravel Engine C++ Reference
Loading...
Searching...
No Matches
statistics_utils.h
Go to the documentation of this file.
1#pragma once
3#include <base/basetypes.hpp>
4#include <array>
5
7{
8
9//-----------------------------------------------------------------------------
14//-----------------------------------------------------------------------------
16{
17public:
18 static constexpr uint32_t NUM_SAMPLES = 500;
19
20 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26
27 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 auto reset(float value) -> void;
34
35 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 auto push_sample(float value) -> void;
43
44 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
50 auto get_values() const -> const float*
51 {
52 return values_.data();
53 }
54
55 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
61 auto get_offset() const -> int32_t
62 {
63 return offset_;
64 }
65
66 //-----------------------------------------------------------------------------
71 //-----------------------------------------------------------------------------
72 auto get_min() const -> float
73 {
74 return min_;
75 }
76
77 //-----------------------------------------------------------------------------
82 //-----------------------------------------------------------------------------
83 auto get_max() const -> float
84 {
85 return max_;
86 }
87
88 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
94 auto get_average() const -> float
95 {
96 return average_;
97 }
98
99private:
100 int32_t offset_{0};
101 std::array<float, NUM_SAMPLES> values_{};
102
103 float min_{0.0f};
104 float max_{0.0f};
105 float average_{0.0f};
106
107 int32_t smart_init_samples_{-1};
108};
109
110//-----------------------------------------------------------------------------
119//-----------------------------------------------------------------------------
120auto draw_progress_bar(float width, float max_width, float height, const ImVec4& color) -> bool;
121
122//-----------------------------------------------------------------------------
132//-----------------------------------------------------------------------------
133auto draw_resource_bar(const char* name,
134 const char* tooltip,
135 uint32_t current_value,
136 uint32_t max_value,
137 float max_width,
138 float height) -> void;
139
140} // namespace unravel::statistics_utils
Class for collecting and managing time-series sample data. Maintains a rolling buffer of samples with...
auto get_max() const -> float
Get the maximum value in the current sample set.
auto get_offset() const -> int32_t
Get the current offset in the rolling buffer.
sample_data()
Constructor that initializes all samples to zero.
auto get_min() const -> float
Get the minimum value in the current sample set.
static constexpr uint32_t NUM_SAMPLES
auto push_sample(float value) -> void
Add a new sample to the rolling buffer. Automatically updates min, max, and average statistics.
auto get_values() const -> const float *
Get the raw sample values array.
auto get_average() const -> float
Get the average value of the current sample set.
auto reset(float value) -> void
Reset all samples to a specific value.
std::string name
Definition hub.cpp:27
const char * tooltip
auto draw_resource_bar(const char *name, const char *tooltip, uint32_t current_value, uint32_t max_value, float max_width, float height) -> void
Draw a resource usage bar with label and percentage.
auto draw_progress_bar(float width, float max_width, float height, const ImVec4 &color) -> bool
Draw a colored progress bar with hover effects.