Use sample_start and sample_end pairs instead of the PROFILER_SAMPLE

macro
This commit is contained in:
2023-07-09 01:52:16 +01:00
parent 0073114723
commit c053d20a8f
3 changed files with 100 additions and 90 deletions

View File

@@ -3,17 +3,16 @@
#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
typedef struct {
const char *title;
u64 start;
u64 end;
} profiler_sample_t;
u64 get_os_frequency();
// Time in nanoseconds
@@ -28,7 +27,8 @@ u64 get_cpu_freq(u64 milliseconds);
void profile_start();
void profile_end();
void add_sample(const char *title, u64 duration);
profiler_sample_t sample_start(const char *title);
void sample_end(profiler_sample_t *sample);
#ifdef __cplusplus
}