2012-03-24 23:39:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
2015-05-13 22:26:51 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2015-05-16 01:14:29 +02:00
|
|
|
// #define USE_PROFILER
|
2012-03-24 23:39:19 +01:00
|
|
|
|
|
|
|
#ifdef USE_PROFILER
|
|
|
|
|
|
|
|
class DrawBuffer;
|
|
|
|
|
2015-05-12 19:50:56 +02:00
|
|
|
void internal_profiler_init();
|
|
|
|
void internal_profiler_end_frame();
|
|
|
|
|
2015-05-13 22:26:51 +02:00
|
|
|
int internal_profiler_enter(const char *category_name); // Returns the category number.
|
2015-05-12 19:50:56 +02:00
|
|
|
void internal_profiler_leave(int category);
|
|
|
|
|
2015-05-13 22:26:51 +02:00
|
|
|
|
|
|
|
const char *Profiler_GetCategoryName(int i);
|
|
|
|
int Profiler_GetNumCategories();
|
|
|
|
int Profiler_GetHistoryLength();
|
|
|
|
void Profiler_GetHistory(int i, float *data, int count);
|
2015-05-12 19:50:56 +02:00
|
|
|
|
|
|
|
class ProfileThis {
|
|
|
|
public:
|
|
|
|
ProfileThis(const char *category) {
|
|
|
|
cat_ = internal_profiler_enter(category);
|
|
|
|
}
|
|
|
|
~ProfileThis() {
|
|
|
|
internal_profiler_leave(cat_);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
int cat_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PROFILE_INIT() internal_profiler_init();
|
|
|
|
#define PROFILE_THIS_SCOPE(cat) ProfileThis _profile_scoped(cat);
|
|
|
|
#define PROFILE_END_FRAME() internal_profiler_end_frame();
|
2012-03-24 23:39:19 +01:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2015-05-12 19:50:56 +02:00
|
|
|
#define PROFILE_INIT()
|
2015-05-13 22:26:51 +02:00
|
|
|
#define PROFILE_THIS_SCOPE(cat)
|
2015-05-12 19:50:56 +02:00
|
|
|
#define PROFILE_END_FRAME()
|
2012-03-24 23:39:19 +01:00
|
|
|
|
|
|
|
#endif
|