blob: 77b52a23003cc13b1e732f6357c981018a9ca7a3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass99dbe4b2015-06-23 15:38:23 -06002/*
3 * (C) Copyright 2015 Google, Inc
Simon Glass99dbe4b2015-06-23 15:38:23 -06004 */
5
6#include <common.h>
7#include <command.h>
Simon Glass391cee42016-03-16 07:44:35 -06008#include <div64.h>
Simon Glass99dbe4b2015-06-23 15:38:23 -06009#include "dhry.h"
10
Simon Glassed38aef2020-05-10 11:40:03 -060011static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
Simon Glass99dbe4b2015-06-23 15:38:23 -060013{
Simon Glass391cee42016-03-16 07:44:35 -060014 ulong start, duration, vax_mips;
15 u64 dhry_per_sec;
Simon Glass99dbe4b2015-06-23 15:38:23 -060016 int iterations = 1000000;
17
18 if (argc > 1)
Simon Glassff9b9032021-07-24 09:03:30 -060019 iterations = dectoul(argv[1], NULL);
Simon Glass99dbe4b2015-06-23 15:38:23 -060020
21 start = get_timer(0);
22 dhry(iterations);
23 duration = get_timer(start);
Simon Glass391cee42016-03-16 07:44:35 -060024 dhry_per_sec = lldiv(iterations * 1000ULL, duration);
Tom Rini98982f62016-03-17 10:14:25 -040025 vax_mips = lldiv(dhry_per_sec, 1757);
Simon Glass99dbe4b2015-06-23 15:38:23 -060026 printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
Simon Glass391cee42016-03-16 07:44:35 -060027 duration, (ulong)dhry_per_sec, vax_mips);
Simon Glass99dbe4b2015-06-23 15:38:23 -060028
29 return 0;
30}
31
32U_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);