[Profiler] Add ability to print elapsed build time for target packages (#14778)

- Why I did it
To be able to see how much time was consumed to build a specific target.
A newly added code does those things:

1. Print build start time for target
2. Print build end time for target
3. Print elapsed time for target

- How I did it
Add a macro to record the time
Add macros to print end time and elapsed time

- How to verify it
Just build an image and check any *.log file

Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
This commit is contained in:
Yevhen Fastiuk 2023-05-03 13:26:22 +03:00 committed by GitHub
parent ef2d08b2ef
commit 46615f5563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,9 @@ LOG = < /dev/null |& $(PROJECT_ROOT)/scripts/process_log.sh $(PROCESS_LOG_OPTION
###############################################################################
## Header and footer for each target
###############################################################################
START_TIME = echo Build start time: $$(date -ud "@$($@_TSTMP_ST)") $(LOG)
END_TIME = echo Build end time: $$(date -ud "@$($@_TSTMP_END)") $(LOG)
ELAPSED_TIME = echo Elapsed time: $$(date -ud "@$$(( $($@_TSTMP_END) - $($@_TSTMP_ST) ))" +'%-Hh %-Mm %-Ss') $(LOG)
# Dump targets taht current depends on
ifeq ($(SONIC_CONFIG_PRINT_DEPENDENCIES),y)
@ -64,11 +67,16 @@ define HEADER
@
$(PRINT_DEPENDENCIES)
$(FLUSH_LOG)
$(eval $@_TSTMP_ST := $(shell date +%s))
$(START_TIME)
./update_screen.sh -a $@ $*
endef
# footer for each rule
define FOOTER
$(eval $@_TSTMP_END := `date +%s`)
$(END_TIME)
$(ELAPSED_TIME)
./update_screen.sh -d $@ $($*_CACHE_LOADED)
endef