]> Git Repo - u-boot.git/blame - cmd/time.c
Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"
[u-boot.git] / cmd / time.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
ca366d0e
CC
2/*
3 * Copyright (c) 2011 The Chromium OS Authors.
ca366d0e
CC
4 */
5
ca366d0e
CC
6#include <command.h>
7
ca366d0e
CC
8static void report_time(ulong cycles)
9{
10 ulong minutes, seconds, milliseconds;
11 ulong total_seconds, remainder;
12
13 total_seconds = cycles / CONFIG_SYS_HZ;
14 remainder = cycles % CONFIG_SYS_HZ;
15 minutes = total_seconds / 60;
16 seconds = total_seconds % 60;
17 /* approximate millisecond value */
18 milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ;
19
20 printf("\ntime:");
21 if (minutes)
22 printf(" %lu minutes,", minutes);
1d643771 23 printf(" %lu.%03lu seconds\n", seconds, milliseconds);
ca366d0e
CC
24}
25
09140113
SG
26static int do_time(struct cmd_tbl *cmdtp, int flag, int argc,
27 char *const argv[])
ca366d0e
CC
28{
29 ulong cycles = 0;
30 int retval = 0;
146dda39 31 int repeatable = 0;
ca366d0e
CC
32
33 if (argc == 1)
4c12eeb8 34 return CMD_RET_USAGE;
ca366d0e 35
34765e88 36 retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles);
ca366d0e
CC
37 report_time(cycles);
38
39 return retval;
40}
41
42U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time,
43 "run commands and summarize execution time",
44 "command [args...]\n");
This page took 0.281796 seconds and 4 git commands to generate.