From 182902ee01692d44b062a984b7d27aa13cce60e0 Mon Sep 17 00:00:00 2001 From: Simon Buhrow Date: Fri, 20 Nov 2020 13:27:20 +0100 Subject: [PATCH] cli_classic.c: Print runtime measurement in seconds in debug To get a fast and easy feedback on how parameters affect runtime (e.g. clock setting, polling delays, etc). The runtime is measured starting from programmer_init and to programmer_shutdown, inclusive. Message is displayed in debug verbosity level. Signed-off-by: Simon Buhrow Change-Id: I2238b3f3e6c2ab7745994662a88787fa2e86d480 Co-Developed-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/47805 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- cli_classic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cli_classic.c b/cli_classic.c index a9f9dc107..0f303c080 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "flash.h" #include "flashchips.h" #include "fmap.h" @@ -1049,6 +1050,7 @@ int main(int argc, char *argv[]) int ret = 0; int all_matched_count = 0; const char **all_matched_names = NULL; + time_t time_start, time_end; struct cli_options options = { 0 }; static const char optstring[] = "r::Rw::v::nNVEfc:l:i:p:Lzho:x"; @@ -1196,6 +1198,8 @@ int main(int argc, char *argv[]) if (flashrom_init(1)) exit(1); + time(&time_start); + if (programmer_init(options.prog, options.pparam)) { msg_perr("Error: Programmer initialization failed.\n"); ret = 1; @@ -1536,6 +1540,11 @@ out: flashrom_data_free(all_matched_names); free_options(&options); + + time(&time_end); + msg_gdbg("Runtime from programmer init to shutdown: %dmin%2dsec\n", + (int)(difftime(time_end, time_start) / 60), (int)(difftime(time_end, time_start)) % 60); + ret |= close_logfile(); return ret; }