Refactor profiling code

This commit is contained in:
2023-07-09 00:55:22 +01:00
parent 2e9c2dc6d5
commit 0073114723
3 changed files with 162 additions and 109 deletions

View File

@@ -3,6 +3,13 @@
#include "aliases.h"
// TODO (Abdelrahman): Not fully satisfied with this solution
#define PROFILER_SAMPLE(ID, TITLE, CODE) \
u64 ID##_start = read_cpu_timer(); \
CODE; \
u64 ID##_end = read_cpu_timer(); \
add_sample(TITLE, ID##_end - ID##_start);
#ifdef __cplusplus
extern "C" {
#endif
@@ -18,6 +25,11 @@ u64 read_cpu_timer(void);
// CPU frequency in hz/sec
u64 get_cpu_freq(u64 milliseconds);
void profile_start();
void profile_end();
void add_sample(const char *title, u64 duration);
#ifdef __cplusplus
}
#endif