From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/u-boot/cmd/time.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 roms/u-boot/cmd/time.c (limited to 'roms/u-boot/cmd/time.c') diff --git a/roms/u-boot/cmd/time.c b/roms/u-boot/cmd/time.c new file mode 100644 index 000000000..db8c1892d --- /dev/null +++ b/roms/u-boot/cmd/time.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2011 The Chromium OS Authors. + */ + +#include +#include + +static void report_time(ulong cycles) +{ + ulong minutes, seconds, milliseconds; + ulong total_seconds, remainder; + + total_seconds = cycles / CONFIG_SYS_HZ; + remainder = cycles % CONFIG_SYS_HZ; + minutes = total_seconds / 60; + seconds = total_seconds % 60; + /* approximate millisecond value */ + milliseconds = (remainder * 1000 + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ; + + printf("\ntime:"); + if (minutes) + printf(" %lu minutes,", minutes); + printf(" %lu.%03lu seconds\n", seconds, milliseconds); +} + +static int do_time(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong cycles = 0; + int retval = 0; + int repeatable = 0; + + if (argc == 1) + return CMD_RET_USAGE; + + retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles); + report_time(cycles); + + return retval; +} + +U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, + "run commands and summarize execution time", + "command [args...]\n"); -- cgit