Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 Google, Inc |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
Simon Glass | f215287 | 2016-03-16 07:44:35 -0600 | [diff] [blame] | 8 | #include <div64.h> |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 9 | #include "dhry.h" |
| 10 | |
| 11 | static int do_dhry(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 12 | { |
Simon Glass | f215287 | 2016-03-16 07:44:35 -0600 | [diff] [blame] | 13 | ulong start, duration, vax_mips; |
| 14 | u64 dhry_per_sec; |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 15 | int iterations = 1000000; |
| 16 | |
| 17 | if (argc > 1) |
| 18 | iterations = simple_strtoul(argv[1], NULL, 10); |
| 19 | |
| 20 | start = get_timer(0); |
| 21 | dhry(iterations); |
| 22 | duration = get_timer(start); |
Simon Glass | f215287 | 2016-03-16 07:44:35 -0600 | [diff] [blame] | 23 | dhry_per_sec = lldiv(iterations * 1000ULL, duration); |
Tom Rini | f23baa5 | 2016-03-17 10:14:25 -0400 | [diff] [blame] | 24 | vax_mips = lldiv(dhry_per_sec, 1757); |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 25 | printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations, |
Simon Glass | f215287 | 2016-03-16 07:44:35 -0600 | [diff] [blame] | 26 | duration, (ulong)dhry_per_sec, vax_mips); |
Simon Glass | d138940 | 2015-06-23 15:38:23 -0600 | [diff] [blame] | 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | U_BOOT_CMD( |
| 32 | dhry, 2, 1, do_dhry, |
| 33 | "[iterations] - run dhrystone benchmark", |
| 34 | "\n - run the Dhrystone 2.1 benchmark, a rough measure of CPU speed\n" |
| 35 | ); |