Message ID | 4EAC146C.8060104@logicpd.com |
---|---|
State | Rejected |
Headers | show |
On Saturday 29 October 2011 10:57:48 Peter Barada wrote: > Add 'time <cmd> <args>' which executes <cmd> with <args> and shows the > execution time in seconds. Requires get_timer(). NAK: we already have common/cmd_time.c and CONFIG_CMD_TIME -mike
Dear Mike Frysinger, In message <201110301113.25446.vapier@gentoo.org> you wrote: > > > Add 'time <cmd> <args>' which executes <cmd> with <args> and shows the > > execution time in seconds. Requires get_timer(). > > NAK: we already have common/cmd_time.c and CONFIG_CMD_TIME But common/cmd_time.c is unportable and only available on ARM due so using a non standard timer API (get_timer_masked() etc. I wonder if we should swap the implementations. Best regards, Wolfgang Denk
On Sunday 30 October 2011 11:55:15 Wolfgang Denk wrote: > Mike Frysinger wrote: > > > Add 'time <cmd> <args>' which executes <cmd> with <args> and shows the > > > execution time in seconds. Requires get_timer(). > > > > NAK: we already have common/cmd_time.c and CONFIG_CMD_TIME > > But common/cmd_time.c is unportable and only available on ARM due so > using a non standard timer API (get_timer_masked() etc. i think the idea was to use the more exact API like will be available with Graeme's proposed rewrite ... > I wonder if we should swap the implementations. extending the current code to support non-ARM makes sense, but adding a new code base like the original patch does not -mike
diff --git a/README b/README index c05c40a..94743af 100644 --- a/README +++ b/README @@ -787,6 +787,7 @@ The following options need to be configured: (requires CONFIG_CMD_MEMORY) CONFIG_CMD_SOURCE "source" command Support CONFIG_CMD_SPI * SPI serial bus support + CONFIG_CMD_TIME times execution of u-boot command CONFIG_CMD_TFTPSRV * TFTP transfer in server mode CONFIG_CMD_TFTPPUT * TFTP put command (upload) CONFIG_CMD_TIME * run command and report execution time diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 061b1bb..d789d44 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -53,3 +53,44 @@ U_BOOT_CMD( "N\n" " - delay execution for N seconds (N is _decimal_ !!!)" ); + +#ifdef CONFIG_CMD_TIME +int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + ulong start; + ulong delta; + cmd_tbl_t *cmdtp2; + int ret; + unsigned int secs, msecs; + + if (argc < 2) + return cmd_usage(cmdtp); + + cmdtp2 = find_cmd(argv[1]); + if (!cmdtp2) { + printf("Unknown command '%s' - try help\n", argv[1]); + return 1; + } + + start = get_timer(0); + + /* Execute command */ + ret = (cmdtp2->cmd)(cmdtp2, flag, argc-1, argv+1); + + delta = get_timer(start); + + secs = (delta * 1000) / CONFIG_SYS_HZ; + msecs = secs % 1000; + secs /= 1000; + + printf("'%s' took %u.%03u seconds\n", argv[1], secs, msecs); + return ret; +} + +U_BOOT_CMD( + time , CONFIG_SYS_MAXARGS, 1, do_time, + "time execution of command", + "command to time\n" + " - time execution of command in seconds" +); +#endif diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 9716f9c..77adc3d 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -82,6 +82,7 @@ #define CONFIG_CMD_SOURCE /* "source" command support */ #define CONFIG_CMD_SPI /* SPI utility */ #define CONFIG_CMD_TERMINAL /* built-in Serial Terminal */ +#define CONFIG_CMD_TIME /* time execution of u-boot cmd */ #define CONFIG_CMD_UBI /* UBI Support */ #define CONFIG_CMD_UBIFS /* UBIFS Support */ #define CONFIG_CMD_UNIVERSE /* Tundra Universe Support */