Rohan G Rohan G - 1 year ago 137
Bash Question

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

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

Answer Source

Just prefix your command lines with time, e.g.: time $(MAKE) -C $$dir.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download