24#ifndef TAPROOT_PROFILER_HPP_
25#define TAPROOT_PROFILER_HPP_
27#include <unordered_map>
29#include "modm/container.hpp"
31#ifdef RUN_WITH_PROFILING
32#define PROFILE(profiler, func, params) \
35 int key = profiler.push(#func); \
40#define PROFILE(profiler, func, params) func params
114 uint32_t
min = UINT32_MAX;
148 std::size_t
push(
const char* profile);
156 void pop(std::size_t key);
161 if (key >= profiledElements.getSize())
167 return profiledElements.get(key);
174 if (key < profiledElements.getSize())
176 profiledElements[key].reset();
189 std::unordered_map<const char*, std::size_t> elementNameToIndexMap;
194 modm::BoundedDeque<ProfilerData, MAX_PROFILED_ELEMENTS> profiledElements;
Definition drivers.hpp:70
Definition profiler.hpp:99
static constexpr std::size_t MAX_PROFILED_ELEMENTS
Max number of profiles that the profiler can store information about.
Definition profiler.hpp:102
void pop(std::size_t key)
Definition profiler.cpp:61
std::size_t push(const char *profile)
Definition profiler.cpp:37
void reset(std::size_t key)
Reset the ProfilerData associated with some particular key.
Definition profiler.hpp:172
ProfilerData getData(std::size_t key)
Definition profiler.hpp:159
static constexpr float AVG_LOW_PASS_ALPHA
Low pass alpha to be used when averaging time it takes for some code to run.
Definition profiler.hpp:104
Definition ballistics.cpp:29
Definition profiler.hpp:110
uint32_t max
Max value, in microseconds, ever recorded by the profiler.
Definition profiler.hpp:116
uint32_t prevPushedTime
Definition profiler.hpp:122
void reset()
Resets the long term profile storage information.
Definition profiler.hpp:128
ProfilerData()
Definition profiler.hpp:124
ProfilerData(const char *name)
Definition profiler.hpp:125
float avg
Average value, in microseconds, averaged using a low pass filter.
Definition profiler.hpp:118
uint32_t min
Min value, in microseconds, ever recorded by the profiler.
Definition profiler.hpp:114
const char * name
Name of the profile.
Definition profiler.hpp:112