From 4bbda865205bf28e497a6628746847a6d3195cef Mon Sep 17 00:00:00 2001 From: TXuian <1163589503@qq.com> Date: Fri, 9 Dec 2022 23:18:14 +0800 Subject: [PATCH] Add Benchmark Sequential --- .../benchmark/support/benchmark.c | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/APP_Framework/Applications/benchmark/support/benchmark.c b/APP_Framework/Applications/benchmark/support/benchmark.c index 0c4ee4647..0726e70d2 100644 --- a/APP_Framework/Applications/benchmark/support/benchmark.c +++ b/APP_Framework/Applications/benchmark/support/benchmark.c @@ -103,13 +103,10 @@ void print_result() { } } -struct wrap_time { - clock_t time; -}; -void *print_result_asyn(void *start_time) { +clock_t g_start_time; +void *print_result_asyn() { clock_t g_stop_time = 0; stop_trigger(&g_stop_time); - struct wrap_time *start_wt = (struct wrap_time *)start_time; int i = 0; while (bmh_list[i].handle != NULL) { printf("[BENCHMARK] Time Cost: %-15s %.4f\n", bmh_list[i].name, @@ -117,7 +114,7 @@ void *print_result_asyn(void *start_time) { i++; } printf("[BENCHMARK] Global Time Diff: %f\n", - (float)((g_stop_time - start_wt->time) / (10 * TICK_PER_SECOND))); + (float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND))); }; int done_cnt = 0; @@ -162,9 +159,7 @@ void *run_benchmark_parallel(void *args) { benchmark_handle *cur_handle = head.next; - // clock_t g_start_time = 0; - struct wrap_time start_time; - start_trigger(&start_time.time); + start_trigger(&g_start_time); while (NULL != cur_handle) { assert(cur_handle->handle.magic_number != MAGIC_NUMBER); PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example, @@ -175,8 +170,7 @@ void *run_benchmark_parallel(void *args) { case_attr.schedparam.sched_priority = 23; case_attr.stacksize = 4096; - PrivTaskCreate(&res_thread, &case_attr, print_result_asyn, - (void *)&start_time); + PrivTaskCreate(&res_thread, &case_attr, print_result_asyn, NULL); return NULL; } @@ -192,10 +186,10 @@ void *run_benchmark_sequential(void *args) { printf("[BENCHMARK] Start Benchmark running sequential.\n"); benchmark_handle *cur_handle = head.next; - clock_t g_start_time = 0, g_stop_time = 0; + clock_t s_start_time = 0, s_stop_time = 0; clock_t start_time = 0, end_time = 0; - start_trigger(&g_start_time); + start_trigger(&s_start_time); while (NULL != cur_handle) { assert(cur_handle->handle.magic_number != MAGIC_NUMBER); cur_handle->handle.benchmark_func->initialise_benchmark(); @@ -212,12 +206,11 @@ void *run_benchmark_sequential(void *args) { cur_handle = cur_handle->next; } - stop_trigger(&g_stop_time); + stop_trigger(&s_stop_time); - clock_t g_time_diff = g_stop_time - g_start_time; print_result(); printf("[BENCHMARK] Global Time Diff: %f\n", - (float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND))); + (float)((s_stop_time - s_start_time) / (10 * TICK_PER_SECOND))); } pthread_t main_thread;