ppsspp/Common/Profiler/Profiler.h

49 lines
1.2 KiB
C
Raw Permalink Normal View History

2012-03-24 22:39:19 +00:00
#pragma once
#include <cstdint>
2015-05-13 20:26:51 +00:00
2015-05-15 23:14:29 +00:00
// #define USE_PROFILER
2012-03-24 22:39:19 +00:00
#ifdef USE_PROFILER
class DrawBuffer;
2015-05-12 17:50:56 +00:00
void internal_profiler_init();
void internal_profiler_end_frame();
int internal_profiler_enter(const char *category_name, int *thread_id); // Returns the category number.
void internal_profiler_leave(int thread_id, int category);
2015-05-12 17:50:56 +00:00
2015-05-13 20:26:51 +00:00
const char *Profiler_GetCategoryName(int i);
int Profiler_GetNumCategories();
int Profiler_GetHistoryLength();
int Profiler_GetNumThreads();
void Profiler_GetSlowestThreads(int *data, int count);
void Profiler_GetSlowestHistory(int category, int *slowestThreads, float *data, int count);
void Profiler_GetHistory(int category, int thread, float *data, int count);
2015-05-12 17:50:56 +00:00
class ProfileThis {
public:
ProfileThis(const char *category) {
cat_ = internal_profiler_enter(category, &thread_);
2015-05-12 17:50:56 +00:00
}
~ProfileThis() {
internal_profiler_leave(thread_, cat_);
2015-05-12 17:50:56 +00:00
}
private:
int cat_;
int thread_;
2015-05-12 17:50:56 +00:00
};
#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 22:39:19 +00:00
#else
2015-05-12 17:50:56 +00:00
#define PROFILE_INIT()
2015-05-13 20:26:51 +00:00
#define PROFILE_THIS_SCOPE(cat)
2015-05-12 17:50:56 +00:00
#define PROFILE_END_FRAME()
2012-03-24 22:39:19 +00:00
#endif