From 973bfe4bd65e1400457a082683ea3e93750ebedc Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 12 Jul 2023 18:58:04 +0300 Subject: [PATCH] remove unused code --- src/json_parser.c | 2 +- src/profiler.c | 5 +++-- src/timer.c | 24 ------------------------ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/json_parser.c b/src/json_parser.c index d8eaf4b..2534240 100644 --- a/src/json_parser.c +++ b/src/json_parser.c @@ -294,7 +294,7 @@ int parse_json_string(struct json_string *result, char *data, size_t data_size) PROF_START("parse_json_string()"); assert(expect_char(data, data_size, '"')); - int json_string_size = get_json_string_size(data, data_size); + u32 json_string_size = get_json_string_size(data, data_size); result->str = malloc((json_string_size-2)*sizeof(char)); result->size = 0; diff --git a/src/profiler.c b/src/profiler.c index ebf8e85..7ff31d9 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -105,7 +105,7 @@ void prof_output() } } - printf("\nTotal time taken: %.3fms\n", (float)total_time*1000/cpu_hz); + printf("\nTotal time taken: %.3fms (%lu)\n", (float)total_time*1000/cpu_hz, total_time); char line_format[128]; snprintf(line_format, ARRAY_LEN(line_format), " %%%ds - %%9lu (%%6.3f%%%%, %%7.3f%%%% w/children) [%%d]\n", label_width); @@ -122,7 +122,8 @@ void prof_output() } u64 other_duration = total_time - profiled_duration; - printf(line_format, "Other", other_duration, (f32)other_duration*100/total_time, 0.0, 1); + f32 other_percent = (f32)other_duration*100/total_time; + printf(line_format, "Other", other_duration, other_percent, other_percent, 1); } #define PROF_START(label) prof_start(__COUNTER__, label) diff --git a/src/timer.c b/src/timer.c index 23d6527..6ebb254 100644 --- a/src/timer.c +++ b/src/timer.c @@ -68,28 +68,4 @@ static u64 get_cpu_timer_hz(u64 measure_time_ms) } } -#define START_TIMER(display) { \ - .start = read_cpu_timer(), \ - .end = 0, \ - .name = display \ - } - -#define END_TIMER(timespan) timespan.end = read_cpu_timer() - -#define TIMER_DURATION(timer) (timer.end - timer.start) - -struct timer { - char *name; - u64 start, end; -}; - -static u64 sum_timer(struct timer *timers, size_t count) -{ - u64 sum = 0; - for (int i = 0; i < count; i++) { - sum += TIMER_DURATION(timers[i]); - } - return sum; -} - #endif //TIMER_