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