]> Git Repo - u-boot.git/blame - cmd/time.c
Revert "Merge 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
d678a59d 6#include <common.h>
ca366d0e
CC
7#include <command.h>
8
ca366d0e
CC
9static void report_time(ulong cycles)
10{
11 ulong minutes, seconds, milliseconds;
12 ulong total_seconds, remainder;
13
14 total_seconds = cycles / CONFIG_SYS_HZ;
15 remainder = cycles % CONFIG_SYS_HZ;
16 minutes = total_seconds / 60;
17 seconds = total_seconds % 60;
18 /* approximate millisecond value */
19 milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ;
20
21 printf("\ntime:");
22 if (minutes)
23 printf(" %lu minutes,", minutes);
1d643771 24 printf(" %lu.%03lu seconds\n", seconds, milliseconds);
ca366d0e
CC
25}
26
09140113
SG
27static int do_time(struct cmd_tbl *cmdtp, int flag, int argc,
28 char *const argv[])
ca366d0e
CC
29{
30 ulong cycles = 0;
31 int retval = 0;
146dda39 32 int repeatable = 0;
ca366d0e
CC
33
34 if (argc == 1)
4c12eeb8 35 return CMD_RET_USAGE;
ca366d0e 36
34765e88 37 retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles);
ca366d0e
CC
38 report_time(cycles);
39
40 return retval;
41}
42
43U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time,
44 "run commands and summarize execution time",
45 "command [args...]\n");
This page took 0.283353 seconds and 4 git commands to generate.