add benchmark to app. TODO: test benchmark.
This commit is contained in:
parent
3288e1dd7a
commit
23ff23bad2
|
@ -102,6 +102,7 @@ void print_result() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int done_cnt = 0;
|
||||||
pthread_mutex_t case_mu;
|
pthread_mutex_t case_mu;
|
||||||
sem_t syn_sem;
|
sem_t syn_sem;
|
||||||
void *run_one_example(void *arg) {
|
void *run_one_example(void *arg) {
|
||||||
|
@ -122,11 +123,12 @@ void *run_one_example(void *arg) {
|
||||||
organize_result(handle, start_time, end_time);
|
organize_result(handle, start_time, end_time);
|
||||||
PrivMutexAbandon(&case_mu);
|
PrivMutexAbandon(&case_mu);
|
||||||
PrivSemaphoreAbandon(&syn_sem);
|
PrivSemaphoreAbandon(&syn_sem);
|
||||||
|
done_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_t case_attr;
|
pthread_attr_t case_attr;
|
||||||
void *run_benchmark(void *args) {
|
void *run_benchmark(void *args) {
|
||||||
int i = 0;
|
done_cnt = 0;
|
||||||
volatile int result;
|
volatile int result;
|
||||||
int correct;
|
int correct;
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ void *run_benchmark(void *args) {
|
||||||
|
|
||||||
case_attr.schedparam.sched_priority = 25;
|
case_attr.schedparam.sched_priority = 25;
|
||||||
case_attr.stacksize = 16384;
|
case_attr.stacksize = 16384;
|
||||||
PrivSemaphoreCreate(&syn_sem, 0, -21);
|
PrivSemaphoreCreate(&syn_sem, 0, -20);
|
||||||
PrivMutexCreate(&case_mu, 0);
|
PrivMutexCreate(&case_mu, 0);
|
||||||
|
|
||||||
benchmark_handle *cur_handle = head.next;
|
benchmark_handle *cur_handle = head.next;
|
||||||
|
@ -153,7 +155,7 @@ void *run_benchmark(void *args) {
|
||||||
|
|
||||||
PrivSemaphoreObtainWait(&syn_sem, NULL);
|
PrivSemaphoreObtainWait(&syn_sem, NULL);
|
||||||
print_result();
|
print_result();
|
||||||
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
|
printf("[BENCHMARK] Global Time Diff: %f, Done: %d\n", global_diff, done_cnt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue