]> git.k1024.org Git - perf-null.git/blob - Makefile
Switch Python to single script + Makefile tricks
[perf-null.git] / Makefile
1 PROGS = \
2         asm/null \
3         c/c-diet-null \
4         c/c-libc-static-null c/c-libc-dynamic-null \
5         c/c++-static-null c/c++-dynamic-null \
6         haskell/null-single haskell/null-threaded \
7         ocaml/null-byte ocaml/null-opt \
8         java/null-gcj-4.6 java/null-gcj-4.8 \
9         java/null-gcj-4.9 java/null-gcj-5
10
11 SCRIPTS = \
12         dash/null.dash bash/null.bash \
13         mksh/null.mksh mksh/null.mksh-static \
14         lua/null.lua51 lua/null.lua52 lua/null.luajit \
15         perl/null.pl \
16         awk/null.mawk awk/null.gawk \
17         ruby/null.rb18 ruby/null.rb19 \
18         php/null.php php/null.php-n \
19         tcl/null.tcl84 tcl/null.tcl85 tcl/null.tcl86
20
21 #METRICS = \
22 #       cycles,instructions,branches,branch-misses \
23 #       dtlb-loads,dtlb-load-misses,itlb-loads,itlb-load-misses \
24 #       cycles,instructions,cache-references,cache-misses \
25 #       cycles,instructions,stalled-cycles-frontend,stalled-cycles-backend
26
27 METRICS = cycles,instructions,branches,branch-misses,cpu-clock,task-clock,major-faults,minor-faults,cs
28
29 JAVA_VMS = server zero cacao jamvm
30 # see below for how this is called
31 JAVA_INVOCS = $(JAVA_VMS:%="java -cp java -% Null")
32
33 PYTHON_VERSIONS ?= python2.7 python3.4 pypy
34 PYTHON_VARIANTS = "" -O -S
35 PYTHON_INVOCS = $(foreach py,$(PYTHON_VERSIONS), \
36         $(foreach opt,$(PYTHON_VARIANTS), "$(py) $(opt) python/null.py"))
37
38 EXTRA_RUN = /bin/true
39
40 REPS = 100
41
42 PERF ?= perf
43
44 all: $(PROGS) java/Null.class
45
46 $(PROGS): Makefile
47
48 asm/null: asm/null.s
49         as -o asm/null.o $<
50         ld -o $@ asm/null.o
51         strip $@
52
53 c-diet-%: %.c
54         diet gcc -O2 -Wall -o $@ $<
55         strip $@
56
57 c-libc-static-%: %.c
58         gcc -static -O2 -Wall -o $@ $<
59         strip $@
60
61 c-libc-dynamic-%: %.c
62         gcc -O2 -Wall -o $@ $<
63         strip $@
64
65 c++-static-%: %.c
66         g++ -static -O2 -Wall -o $@ $<
67         strip $@
68
69 c++-dynamic-%: %.c
70         g++ -O2 -Wall -o $@ $<
71         strip $@
72
73 haskell/null-single: haskell/null.hs
74         ghc --make -O2 -Wall -o $@ $<
75         strip $@
76
77 haskell/null-threaded: haskell/null.hs
78         ghc --make -O2 -Wall -threaded -o $@ $<
79         strip $@
80
81 ocaml/null-byte: ocaml/null.ml
82         ocamlc -o $@ $<
83         # no stripping as this is not an elf file
84
85 ocaml/null-opt: ocaml/null.ml
86         ocamlopt -o $@ $<
87         strip $@
88
89 java/null-gcj-%: java/Null.java
90         gcj-$* --main=Null -o $@ $<
91         strip $@
92
93 java/Null.class: java/Null.java Makefile
94         javac $<
95
96 log: $(PROGS) $(SCRIPTS) java/Null.class Makefile
97         rm -f log; \
98         for prog in $(PROGS:%=./%) $(SCRIPTS:%=./%) \
99           $(EXTRA_RUN) $(JAVA_INVOCS) $(PYTHON_INVOCS); do \
100           echo $$prog; \
101           for metric in $(METRICS); do \
102             LC_ALL=C $(PERF) stat -e "$$metric" -r $(REPS) -o log --append $$prog; \
103           done; \
104         done
105
106 .PHONY: log
107
108 clean:
109         cd asm && rm -f *.o
110         cd haskell && rm -f *.hi *.o
111         cd ocaml && rm -f *.cmo *.cmi *.cmx *.o
112         cd java && rm -f *.class
113         rm -f $(PROGS)