Blame view
common/cmd_time.c
1.01 KB
ca366d0e3 cmd_time: add tim... |
1 2 |
/* * Copyright (c) 2011 The Chromium OS Authors. |
1a4596601 Add GPL-2.0+ SPDX... |
3 |
* SPDX-License-Identifier: GPL-2.0+ |
ca366d0e3 cmd_time: add tim... |
4 5 6 7 |
*/ #include <common.h> #include <command.h> |
ca366d0e3 cmd_time: add tim... |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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(" time:"); if (minutes) printf(" %lu minutes,", minutes); |
1d6437717 cmd_time: do not ... |
24 25 |
printf(" %lu.%03lu seconds ", seconds, milliseconds); |
ca366d0e3 cmd_time: add tim... |
26 27 28 29 30 31 |
} static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong cycles = 0; int retval = 0; |
34765e885 cmd_time: merge r... |
32 |
int repeatable; |
ca366d0e3 cmd_time: add tim... |
33 34 |
if (argc == 1) |
4c12eeb8b Convert cmd_usage... |
35 |
return CMD_RET_USAGE; |
ca366d0e3 cmd_time: add tim... |
36 |
|
34765e885 cmd_time: merge r... |
37 |
retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles); |
ca366d0e3 cmd_time: add tim... |
38 39 40 41 42 43 44 45 46 |
report_time(cycles); return retval; } U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, "run commands and summarize execution time", "command [args...] "); |