Skip to content

Commit

Permalink
Add a dhrystone benchmark command
Browse files Browse the repository at this point in the history
Drystone provides a convenient sanity check that the CPU is running at full
speed. Add this as a command which can be enabled as needed.

Note: I investigated using Coremark for this but there was a license
agreement and I could not work out if it was GPL-compatible.

Signed-off-by: Simon Glass <sjg@chromium.org>
  • Loading branch information
sjg20 committed Jul 21, 2015
1 parent b217c89 commit d138940
Show file tree
Hide file tree
Showing 8 changed files with 1,132 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ config LIB_RAND
help
This library provides pseudo-random number generator functions.

source lib/dhry/Kconfig

source lib/rsa/Kconfig

menu "Hashing Support"
Expand Down
2 changes: 2 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ obj-$(CONFIG_BZIP2) += bzip2/
obj-$(CONFIG_TIZEN) += tizen/
obj-$(CONFIG_OF_LIBFDT) += libfdt/
obj-$(CONFIG_FIT) += libfdt/
obj-$(CONFIG_FIT) += libfdt/
obj-$(CONFIG_CMD_DHRYSTONE) += dhry/

obj-$(CONFIG_AES) += aes.o
obj-$(CONFIG_USB_TTY) += circbuf.o
Expand Down
7 changes: 7 additions & 0 deletions lib/dhry/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config CMD_DHRYSTONE
bool "Support the 'dhry' command to run the dhrystone benchmark"
help
Dhrystone is an old benchmark in the public domain that gives a
rough idea of CPU performance. This enables a 'dhry' command
which runs this benchmark within U-Boot and reports the performance.
The number of 'Dhrystone MIPS' is also reported.
7 changes: 7 additions & 0 deletions lib/dhry/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2015 Google, Inc
#
# SPDX-License-Identifier: GPL-2.0+
#

obj-y += cmd_dhry.o dhry_1.o dhry_2.o
34 changes: 34 additions & 0 deletions lib/dhry/cmd_dhry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* (C) Copyright 2015 Google, Inc
*
* SPDX-License-Identifier: GPL-2.0+
*/

#include <common.h>
#include <command.h>
#include "dhry.h"

static int do_dhry(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong start, duration, dhry_per_sec, vax_mips;
int iterations = 1000000;

if (argc > 1)
iterations = simple_strtoul(argv[1], NULL, 10);

start = get_timer(0);
dhry(iterations);
duration = get_timer(start);
dhry_per_sec = iterations * 1000 / duration;
vax_mips = dhry_per_sec / 1757;
printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
duration, dhry_per_sec, vax_mips);

return 0;
}

U_BOOT_CMD(
dhry, 2, 1, do_dhry,
"[iterations] - run dhrystone benchmark",
"\n - run the Dhrystone 2.1 benchmark, a rough measure of CPU speed\n"
);
442 changes: 442 additions & 0 deletions lib/dhry/dhry.h

Large diffs are not rendered by default.

Loading

0 comments on commit d138940

Please sign in to comment.