Add Benchmark Sequential

This commit is contained in:
TXuian 2022-12-09 22:10:35 +08:00
parent 1fe282e70b
commit f23dbf8305
1 changed files with 19 additions and 7 deletions

View File

@ -143,12 +143,15 @@ void *run_benchmark_parallel(void *args) {
init_benchmark_runset(&head);
printf("[BENCHMARK] Start Benchmark running parallel.\n");
case_attr.schedparam.sched_priority = 30;
case_attr.schedparam.sched_priority = 20;
case_attr.stacksize = 16384;
PrivSemaphoreCreate(&syn_sem, 0, -21);
PrivMutexCreate(&case_mu, 0);
benchmark_handle *cur_handle = head.next;
clock_t g_start_time = 0, g_stop_time = 0;
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,
@ -156,12 +159,15 @@ void *run_benchmark_parallel(void *args) {
cur_handle = cur_handle->next;
}
struct timespec abstime;
abstime.tv_sec = 10;
PrivSemaphoreObtainWait(&syn_sem, &abstime);
stop_trigger(&g_stop_time);
print_result();
printf("[BENCHMARK] Global Time Diff: %f, Done: %d\n", global_diff, done_cnt);
printf("[BENCHMARK] Global Time Diff: %f\n",
(float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND)));
return NULL;
}
@ -176,9 +182,13 @@ void *run_benchmark_sequential(void *args) {
init_benchmark_runset(&head);
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 start_time = 0, end_time = 0;
start_trigger(&g_start_time);
while (NULL != cur_handle) {
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
clock_t start_time = 0, end_time = 0;
cur_handle->handle.benchmark_func->initialise_benchmark();
cur_handle->handle.benchmark_func->warm_caches(WARMUP_HEAT);
start_trigger(&start_time);
@ -189,13 +199,15 @@ void *run_benchmark_sequential(void *args) {
if (!correct) {
printf("[EmBench] Wrong result!.\n");
}
organize_result(cur_handle, start_time, end_time);
cur_handle = cur_handle->next;
}
stop_trigger(&g_stop_time);
print_result();
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
printf("[BENCHMARK] Global Time Diff: %f\n",
(float)((g_stop_time - g_start_time) / (10 * TICK_PER_SECOND)));
}
pthread_t main_thread;
@ -207,7 +219,7 @@ static int embenchmark_parallel() {
return 0;
}
static int embenchmark_sequential(void) {
case_attr.schedparam.sched_priority = 30;
case_attr.schedparam.sched_priority = 20;
case_attr.stacksize = 16384;
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_sequential, NULL);
return 0;