1

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)

Rohan G
  • 19
  • 5
  • Please show us your work. Also take for instance a simple makefile specifying a debug build option and a release build option. running the debug build and the release afterwards might make the release build seem to run very fast. One recipe can influence other recipes build time. – Work of Artiz Aug 24 '16 at 09:51
  • Side note: http://stackoverflow.com/q/6966877/4153464 This might be what you're looking for. It won't interpret your makefile but its likely close enough – Work of Artiz Aug 24 '16 at 09:55
  • @Work of Artiz in this case i have only one recipe. Other build thing i am not getting can you more specify it. – Rohan G Aug 24 '16 at 10:04
  • _Important_ to know: _Make_ will expand the entire recipe (which is stored as a single recursively expanded variable) as the first step in working out what to pass to the shell. It then runs each line of the expansion one-by-one, each in a separate shell invocation. The upshot of this is that both of your `$(eval...)`s will run at expansion time, before the shell gets to do anything at all. – bobbogo Sep 02 '16 at 10:41

1 Answers1

1

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

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271