blob: e52beaeaadc735d4659affb8d995bc71667bff49 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassd1389402015-06-23 15:38:23 -06002/*
3 * (C) Copyright 2015 Google, Inc
Simon Glassd1389402015-06-23 15:38:23 -06004 */
5
Simon Glassd1389402015-06-23 15:38:23 -06006#include <command.h>
Simon Glassf2152872016-03-16 07:44:35 -06007#include <div64.h>
Tom Rini467382c2023-12-14 13:16:58 -05008#include <time.h>
9#include <vsprintf.h>
Simon Glassd1389402015-06-23 15:38:23 -060010#include "dhry.h"
11
Simon Glass09140112020-05-10 11:40:03 -060012static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc,
13 char *const argv[])
Simon Glassd1389402015-06-23 15:38:23 -060014{
Simon Glassf2152872016-03-16 07:44:35 -060015 ulong start, duration, vax_mips;
16 u64 dhry_per_sec;
Simon Glassd1389402015-06-23 15:38:23 -060017 int iterations = 1000000;
18
19 if (argc > 1)
Simon Glass0b1284e2021-07-24 09:03:30 -060020 iterations = dectoul(argv[1], NULL);
Simon Glassd1389402015-06-23 15:38:23 -060021
22 start = get_timer(0);
23 dhry(iterations);
24 duration = get_timer(start);
Simon Glassf2152872016-03-16 07:44:35 -060025 dhry_per_sec = lldiv(iterations * 1000ULL, duration);
Tom Rinif23baa52016-03-17 10:14:25 -040026 vax_mips = lldiv(dhry_per_sec, 1757);
Simon Glassd1389402015-06-23 15:38:23 -060027 printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
Simon Glassf2152872016-03-16 07:44:35 -060028 duration, (ulong)dhry_per_sec, vax_mips);
Simon Glassd1389402015-06-23 15:38:23 -060029
30 return 0;
31}
32
33U_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);