mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
Added profiler implementation based on RAII.
This commit is contained in:
parent
767bd19c36
commit
e186eb757c
36
include/sta/debug/profile.hpp
Normal file
36
include/sta/debug/profile.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* profile.hpp
|
||||||
|
*
|
||||||
|
* Created on: May 22, 2024
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STA_DEBUGGING_PROFILING_HPP
|
||||||
|
#define STA_DEBUGGING_PROFILING_HPP
|
||||||
|
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
class Profiler {
|
||||||
|
public:
|
||||||
|
Profiler(const char* name);
|
||||||
|
|
||||||
|
~Profiler();
|
||||||
|
private:
|
||||||
|
const char* name_;
|
||||||
|
uint32_t start_;
|
||||||
|
};
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define STA_TIME_IT(name) sta::Profiler profiler(name);
|
||||||
|
|
||||||
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
#define STA_TIME_IT(name) ((void)0)
|
||||||
|
|
||||||
|
#endif // STA_DEBUGGING_PROFILING_HPP
|
29
src/debug/profile.cpp
Normal file
29
src/debug/profile.cpp
Normal 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
|
Loading…
x
Reference in New Issue
Block a user