简体   繁体   中英

Build time for makefile recipe

I want to caluclate time spent for each recipe in makefile

SYS_TIME = $(shell date)
SUBDIRS = a b c d

.PHONY = default

default:
    for dir in $(SUBDIRS); \
    do \
       $(eval ST = $(SYS_TIME)) \
       $(MAKE) -C FOLD=$$dir; \
       $(eval ET = $(SYS_TIME))
       echo "time spent  =   $(ST) - $(ET) "
   done; \

result should look like:

time spent = 1:35

time spent = 2:23

time spent = 10:59

time spent = 5:35

it signify 1 minute 35 sec for first and same for others

or some other alternative for $(shell date)

只需在命令行前面加上time ,例如: time $(MAKE) -C $$dir

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM