xref: /openbmc/u-boot/lib/dhry/cmd_dhry.c (revision 00a457b2)
1 /*
2  * (C) Copyright 2015 Google, Inc
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <command.h>
9 #include "dhry.h"
10 
11 static int do_dhry(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
12 {
13 	ulong start, duration, dhry_per_sec, vax_mips;
14 	int iterations = 1000000;
15 
16 	if (argc > 1)
17 		iterations = simple_strtoul(argv[1], NULL, 10);
18 
19 	start = get_timer(0);
20 	dhry(iterations);
21 	duration = get_timer(start);
22 	dhry_per_sec = iterations * 1000 / duration;
23 	vax_mips = dhry_per_sec / 1757;
24 	printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
25 	       duration, dhry_per_sec, vax_mips);
26 
27 	return 0;
28 }
29 
30 U_BOOT_CMD(
31 	dhry,	2,	1,	do_dhry,
32 	"[iterations] - run dhrystone benchmark",
33 	"\n    - run the Dhrystone 2.1 benchmark, a rough measure of CPU speed\n"
34 );
35