Update the profiler to allow for different level of profiling

This commit is contained in:
2023-07-23 16:36:21 +01:00
parent 0e973feb38
commit 19c02b4e99
4 changed files with 56 additions and 46 deletions

View File

@@ -1,23 +0,0 @@
#ifndef PROFILER_IDS_H
#define PROFILER_IDS_H
enum profiler_ids {
PROFILER_ID_CLI_PARSE,
PROFILER_ID_JSON_PARSE,
PROFILER_ID_READ_JSON_FILE,
PROFILER_ID_PARSER_SETUP,
PROFILER_ID_LEX_GET_TOKEN,
PROFILER_ID_PARSE_TOKEN,
PROFILER_ID_PARSER_TEAR_DOWN,
PROFILER_ID_LOAD_JSON_PAIRS,
PROFILER_ID_READ_BINARY,
PROFILER_ID_HAVERSINE_SUM,
PROFILER_ID_HAVERSINE_DISTANCE,
PROFILER_ID_HAVERSINE_AVG,
PROFILER_ID_TEAR_DOWN,
PROFILER_ID_FREE_JSON,
COUNT_PROFILER_IDS,
};
#endif // !PROFILER_IDS_H

View File

@@ -7,17 +7,29 @@
#define MAX_PROFILE_SAMPLES 1024
#endif // !MAX_PROFILE_SAMPLES
#ifdef ENABLE_PROFILING
#define PROFILE_START(COUNT) profile_start(COUNT)
#define PROFILE_END profile_end()
#ifdef FULL_PROFILING
#define SAMPLE_START(ID, TITLE) sample_start(ID, TITLE)
#define SAMPLE_END(ID) sample_end(ID)
#ifdef __cplusplus
extern "C" {
#endif
void sample_start(u64 id, const char *title);
void sample_end(u64 id);
#ifdef __cplusplus
}
#endif
#else
#define PROFILE_START(COUNT)
#define PROFILE_END
#define SAMPLE_START(ID, TITLE)
#define SAMPLE_END(ID)
#endif // ENABLE_PROFILING
#endif // FULL_PROFILING
#if defined(BASIC_PROFILING) || defined(FULL_PROFILING)
#define PROFILE_START(COUNT) profile_start(COUNT)
#define PROFILE_END profile_end()
#ifdef __cplusplus
extern "C" {
@@ -49,11 +61,13 @@ u64 get_cpu_freq(u64 milliseconds);
void profile_start(u64 count);
void profile_end();
void sample_start(u64 id, const char *title);
void sample_end(u64 id);
#ifdef __cplusplus
}
#endif
#else
#define PROFILE_START(COUNT)
#define PROFILE_END
#endif // BASIC_PROFILING || FULL_PROFILING
#endif // !TIMER_H