commands: Add dhrystone
PATCH v3 1/1 commands: Add dhrystone
This tool will help to measure the system performance.
Some SoCs haven't the possibility to route their clocks to the output pins. So you can use dhrystone to get a feedback about the clock speed.
---
Changes:
v1:
applied RFC suggestions:
-removed 'default n' in Kconfig
-refactored time defines with default time units -only print variable values when values are wrong -added units to printf
-the iteration parameter is now optional. The programm starts with 10000 iterations and adjust higher, when execution time is too short.
-changed variable name (microseconds -> nanoseconds) -corrected the command description
v2:
refactored globale variables
changed malloc calls
v3:
moved benchmark execution in a new function
build a wrapper around this function to adjust the iterations better
commands/Kconfig | 6 + commands/Makefile | 1 + commands/dhrystone.c | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 464 insertions(+) create mode 100644 commands/dhrystone.c
commands/Kconfig +6 -0
@@ -2102,6 +2102,12 @@ config CMD_STATE depends on STATE prompt "state" +config CMD_DHRYSTONE + bool + prompt "dhrystone" + help + CPU benchmark tool + # end Miscellaneous commands endmenu
commands/Makefile +1 -0
@@ -112,3 +112,4 @@ obj-$(CONFIG_CMD_NV) += nv.o obj-$(CONFIG_CMD_DEFAULTENV) += defaultenv.o obj-$(CONFIG_CMD_STATE) += state.o obj-$(CONFIG_CMD_DHCP) += dhcp.o +obj-$(CONFIG_CMD_DHRYSTONE) += dhrystone.o
commands/dhrystone.c new file +457 -0
457 lines not on this page · raw message
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Daniel,
Quoted 9 lines · Daniel Schultz
This tool will help to measure the system performance.
Some SoCs haven't the possibility to route their clocks to the output pins. So you can use dhrystone to get a feedback about the clock speed.
Signed-off-by Daniel Schultz <[email protected]>---
+enum idents
compare_chars(char char_1, char char_2)
All functions only used locally should be static.
Quoted 58 lines
commands/dhrystone.c new file +57
-0+{ +if (char_1 != char_2) { +return ident_1; + }else {/* should not executed */ + char_1_glob = char_1; +return ident_2; + } +} + +bool compare_strs (char str_1[31 ],char str_2[31 ]) +{ +int offset; + + offset =2 ; +while (offset <=2 ) +if (compare_chars (str_1[offset], str_2[offset+1 ]) == ident_1) + ++offset; +if (strcmp (str_1, str_2) >0 ) { + int_glob = offset +7 ; +return true; + }else { +return false; + } + +} + +bool check_ident (enum idents ident) +{ +if (ident == ident_3) +return true; +else +return false; +} + +static void execution (u32 number_of_runs,u64 *start_time,u64 *end_time) +{ +int int_1; +int int_2; +int int_3; +char char_i; +enum idents ident; +char str_1[31 ]; +char str_2[31 ]; +int i; + + ident = ident_2;/* prevent compiler warning */ + int_2 =0 ;/* prevent compiler warning */ + int_3 =0 ;/* prevent compiler warning */ + + record_glob->ptr_comp = next_record_glob; + record_glob->discr = ident_1; + record_glob->variant.var_1.enum_comp = ident_3; + record_glob->variant.var_1.int_comp =40 ; +strcpy (record_glob->variant.var_1.str_comp, +"DHRYSTONE PROGRAM, SOME STRING" ); +strcpy (str_1,"DHRYSTONE PROGRAM, 1'ST STRING" ); +
commands/dhrystone.c
Quoted 10 lines
commands/dhrystone.c new file +10
-0+ arr_2_glob[8 ][7 ] =10 ; +/* Was missing in published program. Without this statement, */ +/* arr_2_glob [8][7] would have an undefined value. */ +/* Warning: With 16-Bit processors and number_of_runs > 32000, */ +/* overflow may occur for this array element. */ + +/***************/ +/* Start timer */ +/***************/ + *start_time =get_time_ns ();
What I aimed at was a behaviour like outlined below, basically a run-until-enough-time-elapsed:
static void dhrystone(int number_of_runs, u64 *difftime)
{
u64 start;
int now;
if (number_of_runs)
now = number_of_runs;
else
now = 10000;
start = get_time_ns();again:
for (i = 0; i < now; i++) do_one_run; *difftime = get_time_ns() - start; if (number_of_runs) return; if (*difftime < TOO_SMALL_TIME) goto again; }
Other than that this version looks much better than the last one, we're getting closer ;)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox