/src/u-boot/lib/dhry/cmd_dhry.c
Line | Count | Source |
1 | | // SPDX-License-Identifier: GPL-2.0+ |
2 | | /* |
3 | | * (C) Copyright 2015 Google, Inc |
4 | | */ |
5 | | |
6 | | #include <command.h> |
7 | | #include <div64.h> |
8 | | #include <time.h> |
9 | | #include <vsprintf.h> |
10 | | #include "dhry.h" |
11 | | |
12 | | static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc, |
13 | | char *const argv[]) |
14 | 0 | { |
15 | 0 | ulong start, duration, vax_mips; |
16 | 0 | u64 dhry_per_sec; |
17 | 0 | int iterations = 1000000; |
18 | |
|
19 | 0 | if (argc > 1) |
20 | 0 | iterations = dectoul(argv[1], NULL); |
21 | |
|
22 | 0 | start = get_timer(0); |
23 | 0 | dhry(iterations); |
24 | 0 | duration = get_timer(start); |
25 | 0 | dhry_per_sec = lldiv(iterations * 1000ULL, duration); |
26 | 0 | vax_mips = lldiv(dhry_per_sec, 1757); |
27 | 0 | printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations, |
28 | 0 | duration, (ulong)dhry_per_sec, vax_mips); |
29 | |
|
30 | 0 | return 0; |
31 | 0 | } |
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 | | ); |