time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

makefile (1226B)


      1 # Interface: 
      2 #   make
      3 #   make build
      4 #   make run
      5 #   make time-linux
      6 #   make install
      7 #   make format
      8 #   make time-linux-simple
      9 #   make profile-linux
     10 
     11 # Main file
     12 SRC=samples.lang
     13 OUTPUT=out/samples
     14 
     15 # Compiler
     16 COMPILER=lang-compiler
     17 FLAGS=
     18 
     19 ## Formatter
     20 FORMATTER=lang-formatter --options
     21 
     22 ## make build
     23 build: $(SRC)
     24 	$(COMPILER) $(FLAGS) -o $(OUTPUT)
     25 
     26 install:
     27 	lang-package-manager install dependencies
     28 
     29 format: $(SRC)
     30 	$(FORMATTER) $(SRC)
     31 
     32 run: $(SRC) $(OUTPUT)
     33 	./$(OUTPUT)
     34 
     35 time-linux: 
     36 	@echo "Requires /bin/time, found on GNU/Linux systems" && echo
     37 	@echo "Running 100x and taking avg time of: $(OUTPUT)"
     38 	@t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time: |" | sed 's|$$|ms|' && echo
     39 	
     40 time-linux-simple:
     41 	@echo "Requires /bin/time, found on GNU/Linux systems" && echo
     42 	/bin/time -f "Time: %es" ./$(OUTPUT) && echo
     43 
     44 profile-linux: 
     45 	@echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar"
     46 	@echo "Must be run as sudo"
     47 	sudo perf record $(OUTPUT)
     48 	sudo perf report
     49 	rm perf.data