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