Add Benchmark Sequential
This commit is contained in:
parent
c5acbb1ca9
commit
5549eb0271
|
@ -1,5 +1,3 @@
|
|||
#ifndef _BENCHMARK_H_
|
||||
#define _BENCHMARK_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -105,9 +103,13 @@ void print_result() {
|
|||
}
|
||||
}
|
||||
|
||||
void *print_result_asyn(void *g_start_time) {
|
||||
struct wrap_time {
|
||||
clock_t time;
|
||||
};
|
||||
void *print_result_asyn(void *start_time) {
|
||||
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,
|
||||
|
@ -115,13 +117,11 @@ void *print_result_asyn(void *g_start_time) {
|
|||
i++;
|
||||
}
|
||||
printf("[BENCHMARK] Global Time Diff: %f\n",
|
||||
(float)((g_stop_time - *(clock_t *)g_start_time) /
|
||||
(10 * TICK_PER_SECOND)));
|
||||
(float)((g_stop_time - start_wt->time) / (10 * TICK_PER_SECOND)));
|
||||
};
|
||||
|
||||
int done_cnt = 0;
|
||||
pthread_mutex_t case_mu;
|
||||
sem_t syn_sem;
|
||||
void *run_one_example(void *arg) {
|
||||
const benchmark_handle *handle = arg;
|
||||
assert(handle != NULL);
|
||||
|
@ -140,8 +140,6 @@ void *run_one_example(void *arg) {
|
|||
PrivMutexObtain(&case_mu);
|
||||
organize_result(handle, start_time, end_time);
|
||||
PrivMutexAbandon(&case_mu);
|
||||
PrivSemaphoreAbandon(&syn_sem);
|
||||
done_cnt++;
|
||||
}
|
||||
|
||||
pthread_attr_t case_attr;
|
||||
|
@ -165,8 +163,9 @@ void *run_benchmark_parallel(void *args) {
|
|||
|
||||
benchmark_handle *cur_handle = head.next;
|
||||
|
||||
clock_t g_start_time = 0;
|
||||
start_trigger(&g_start_time);
|
||||
// clock_t g_start_time = 0;
|
||||
struct wrap_time start_time;
|
||||
start_trigger(&start_time.time);
|
||||
while (NULL != cur_handle) {
|
||||
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
||||
PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example,
|
||||
|
@ -178,7 +177,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 *)&g_start_time);
|
||||
(void *)&start_time);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -240,5 +239,3 @@ PRIV_SHELL_CMD_FUNCTION(embenchmark_parallel, run benchmark in parallel,
|
|||
PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
PRIV_SHELL_CMD_FUNCTION(embenchmark_sequential, run benchmark in sequential,
|
||||
PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue