Blame view
common/cmd_time.c
1.03 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 24 25 26 27 28 29 30 31 32 |
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); printf(" %lu.%03lu seconds, %lu ticks ", seconds, milliseconds, cycles); } 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... |
33 |
int repeatable; |
ca366d0e3 cmd_time: add tim... |
34 35 |
if (argc == 1) |
4c12eeb8b Convert cmd_usage... |
36 |
return CMD_RET_USAGE; |
ca366d0e3 cmd_time: add tim... |
37 |
|
34765e885 cmd_time: merge r... |
38 |
retval = cmd_process(0, argc - 1, argv + 1, &repeatable, &cycles); |
ca366d0e3 cmd_time: add tim... |
39 40 41 42 43 44 45 46 47 |
report_time(cycles); return retval; } U_BOOT_CMD(time, CONFIG_SYS_MAXARGS, 0, do_time, "run commands and summarize execution time", "command [args...] "); |