Added profiler implementation based on RAII.

This commit is contained in:
dario
2024-05-24 15:37:55 +02:00
parent 767bd19c36
commit e186eb757c
2 changed files with 65 additions and 0 deletions

29
src/debug/profile.cpp Normal file
View File

@@ -0,0 +1,29 @@
/*
* profiler.cpp
*
* Created on: May 22, 2024
* Author: Dario
*/
#include <sta/debug/profile.hpp>
#ifdef STA_DEBUGGING_ENABLED
#include <sta/time.hpp>
namespace sta
{
Profiler::Profiler(const char* name)
: name_{name},
start_{timeUs()}
{
}
Profiler::~Profiler()
{
STA_DEBUG_PRINTF("[PROFILER] %s took %d us", name_, timeUs() - start_);
}
} // namespace sta
#endif // STA_DEBUGGING_ENABLED