feat: make profiler compile time define

This commit is contained in:
Hayden Kowalchuk 2020-03-05 14:57:51 -05:00
parent 5a89fbcd7d
commit a285c42c5f
2 changed files with 22 additions and 5 deletions

View File

@ -6,6 +6,8 @@
#include "profiler.h" #include "profiler.h"
#include "../containers/aligned_vector.h" #include "../containers/aligned_vector.h"
#if PROFILING_COMPILED
#define MAX_PATH 256 #define MAX_PATH 256
typedef struct { typedef struct {
@ -141,3 +143,4 @@ void profiler_print_stats() {
fprintf(stderr, "%-60s%-20f%-20f%" PRIu64 "\n", result->name, (double)avg, (double)ms, result->total_calls); fprintf(stderr, "%-60s%-20f%-20f%" PRIu64 "\n", result->name, (double)avg, (double)ms, result->total_calls);
} }
} }
#endif

View File

@ -7,12 +7,26 @@ typedef struct {
uint64_t start_time_in_us; uint64_t start_time_in_us;
} Profiler; } Profiler;
#define PROFILING_COMPILED 0
#if PROFILING_COMPILED
Profiler* profiler_push(const char* name); Profiler* profiler_push(const char* name);
void profiler_checkpoint(const char* name); void _profiler_checkpoint(const char* name);
void profiler_pop(); void _profiler_pop();
void profiler_print_stats(); void _profiler_print_stats();
void profiler_enable(); void _profiler_enable();
void profiler_disable(); void _profiler_disable();
#else
#define profiler_push(name);
#define profiler_checkpoint(name);
#define profiler_pop();
#define profiler_print_stats();
#define profiler_enable();
#define profiler_disable();
#endif