add benchmark to app. TODO: test benchmark.

This commit is contained in:
TXuian 2022-12-07 15:39:54 +08:00
parent 07b1f5da5b
commit fbc7d384f0
4 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
# SRC_FILES := beebsc.c benchmark.c # SRC_FILES := beebsc.c benchmark.c
SRC_FILES := $(wildcard src/*/*.c) SRC_FILES += $(wildcard *.c)
# include $(APPDIR)/Application.mk # include $(APPDIR)/Application.mk
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -12,7 +12,9 @@
#ifndef BEEBSC_H #ifndef BEEBSC_H
#define BEEBSC_H #define BEEBSC_H
#include <assert.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h>
/* BEEBS fixes RAND_MAX to its lowest permitted value, 2^15-1 */ /* BEEBS fixes RAND_MAX to its lowest permitted value, 2^15-1 */
@ -36,10 +38,13 @@
This function just*/ This function just*/
// #define assert_beebs(expr) \
// { \
// if (!(expr)) exit(1); \
// }
#define assert_beebs(expr) \ #define assert_beebs(expr) \
{ \ { assert(expr); }
if (!(expr)) exit(1); \
}
#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

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <support.h> #include <support.h>
#include <time.h> #include <time.h>
#include <transform.h>
extern benchmark_handle mont64_handle; extern benchmark_handle mont64_handle;
extern benchmark_handle crc32_handle; extern benchmark_handle crc32_handle;
@ -70,8 +71,8 @@ float tmp_diff = 0.0;
float global_diff = 0.0; float global_diff = 0.0;
clock_t start_time = 0, end_time = 0; clock_t start_time = 0, end_time = 0;
void start_trigger(void) { start_time = clock(); } void start_trigger(void) { start_time = PrivGetTickTime(); }
void stop_trigger(void) { end_time = clock(); } void stop_trigger(void) { end_time = PrivGetTickTime(); }
void init_benchmark_runset() { void init_benchmark_runset() {
int i = 0; int i = 0;
@ -80,7 +81,7 @@ void init_benchmark_runset() {
} }
} }
void organize_result(const benchmark_handle *handle) { void organize_result(const benchmark_handle *handle) {
tmp_diff = (float)(end_time - start_time) / CLOCKS_PER_SEC; tmp_diff = (float)(end_time - start_time) / TICK_PER_SECOND;
global_diff += tmp_diff; global_diff += tmp_diff;
int i = 0; int i = 0;
while (bmh_list[i].handle != NULL) { while (bmh_list[i].handle != NULL) {
@ -132,11 +133,11 @@ int run_benchmark() {
return (!correct); return (!correct);
} }
int embenchmark() { static int embenchmark(void) {
run_benchmark(); run_benchmark();
printf("[BENCHMARK] Global Time Diff: %f\n", global_diff); printf("[BENCHMARK] Global Time Diff: %f\n", global_diff);
return 0; return 0;
} }
PRIV_SHELL_CMD_FUNCTION(embenchmark, run embenchmark, PRIV_SHELL_CMD_MAIN_ATTR); PRIV_SHELL_CMD_FUNCTION(embenchmark, benchmark, PRIV_SHELL_CMD_MAIN_ATTR);
#endif #endif

View File

@ -497,7 +497,7 @@ endif
endif endif
# ifeq ($(CONFIG_BENCHMARK), y) ifeq ($(CONFIG_APP_BENCHMARK), y)
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/support KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/support
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/cubic \ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/cubic \
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/picojpeg \ -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/picojpeg \
@ -505,7 +505,7 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/c
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/sglib-combined \ -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/sglib-combined \
-I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/slre \ -I$(KERNEL_ROOT)/../../APP_Framework/Applications/benchmark/src/slre \
-lm -lm
# endif endif
ifeq ($(CONFIG_TOOL_SHELL), y) ifeq ($(CONFIG_TOOL_SHELL), y)