add benchmark to app. TODO: test benchmark.

This commit is contained in:
TXuian 2022-12-07 17:25:19 +08:00
parent 958d8e26df
commit 846743982b
2 changed files with 10 additions and 10 deletions

View File

@ -43,13 +43,8 @@
// if (!(expr)) exit(1); \ // if (!(expr)) exit(1); \
// } // }
// #define assert_beebs(expr) \
// { assert(expr); }
#define assert_beebs(expr) \ #define assert_beebs(expr) \
{ \ { assert(expr); }
if (!(expr)) return; \
}
#define float_eq_beebs(exp, actual) (fabsf(exp - actual) < VERIFY_FLOAT_EPS) #define float_eq_beebs(exp, actual) (fabsf(exp - actual) < VERIFY_FLOAT_EPS)
#define float_neq_beebs(exp, actual) !float_eq_beebs(exp, actual) #define float_neq_beebs(exp, actual) !float_eq_beebs(exp, actual)

View File

@ -104,7 +104,7 @@ void print_result() {
} }
}; };
int run_benchmark() { void *run_benchmark(void *args) {
int i = 0; int i = 0;
volatile int result; volatile int result;
int correct; int correct;
@ -137,12 +137,17 @@ int run_benchmark() {
} }
// print_result(); // print_result();
return (!correct); printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
return NULL;
} }
pthread_t benchmark_task;
static int embenchmark(void) { static int embenchmark(void) {
run_benchmark(); pthread_attr_t attr;
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff); attr.schedparam.sched_priority = 25;
attr.stacksize = 4096;
PrivTaskCreate(&benchmark_task, &attr, run_benchmark, NULL);
return 0; return 0;
} }
PRIV_SHELL_CMD_FUNCTION(embenchmark, benchmark, PRIV_SHELL_CMD_MAIN_ATTR); PRIV_SHELL_CMD_FUNCTION(embenchmark, benchmark, PRIV_SHELL_CMD_MAIN_ATTR);