]> git.k1024.org Git - perf-null.git/blob - Makefile
Move ruby to makefile + versions
[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         perl/null.pl \
15         awk/null.mawk awk/null.gawk \
16         php/null.php php/null.php-n \
17         tcl/null.tcl84 tcl/null.tcl85 tcl/null.tcl86
18
19 #METRICS = \
20 #       cycles,instructions,branches,branch-misses \
21 #       dtlb-loads,dtlb-load-misses,itlb-loads,itlb-load-misses \
22 #       cycles,instructions,cache-references,cache-misses \
23 #       cycles,instructions,stalled-cycles-frontend,stalled-cycles-backend
24
25 METRICS = cycles,instructions,branches,branch-misses,cpu-clock,task-clock,major-faults,minor-faults,cs
26
27 JAVA_VMS = server zero cacao jamvm
28 # see below for how this is called
29 JAVA_TARGETS = $(JAVA_VMS:%="java -cp java -% Null")
30
31 PYTHON_VERSIONS ?= python2.7 python3.4 pypy
32 PYTHON_VARIANTS = "" -O -S
33 PYTHON_TARGETS = $(foreach py,$(PYTHON_VERSIONS), \
34         $(foreach opt,$(PYTHON_VARIANTS), "$(py) $(opt) python/null.py"))
35
36 LUA_VERSIONS ?= lua5.1 lua5.2 luajit
37 LUA_TARGETS = $(LUA_VERSIONS:%="% lua/null.lua")
38
39 RUBY_VERSIONS ?= ruby2.1 ruby2.2
40 RUBY_TARGETS = $(RUBY_VERSIONS:%="% ruby/null.rb")
41
42 EXTRA_RUN = /bin/true
43
44 ALL_TARGETS = \
45   $(PROGS:%=./%) \
46   $(SCRIPTS:%=./%) \
47   $(JAVA_TARGETS) \
48   $(PYTHON_TARGETS) \
49   $(LUA_TARGETS) \
50   $(EXTRA_RUN)
51
52 REPS ?= 100
53
54 PERF ?= perf
55
56 all: $(PROGS) java/Null.class
57
58 $(PROGS): Makefile
59
60 asm/null: asm/null.s
61         as -o asm/null.o $<
62         ld -o $@ asm/null.o
63         strip $@
64
65 c-diet-%: %.c
66         diet gcc -O2 -Wall -o $@ $<
67         strip $@
68
69 c-libc-static-%: %.c
70         gcc -static -O2 -Wall -o $@ $<
71         strip $@
72
73 c-libc-dynamic-%: %.c
74         gcc -O2 -Wall -o $@ $<
75         strip $@
76
77 c++-static-%: %.c
78         g++ -static -O2 -Wall -o $@ $<
79         strip $@
80
81 c++-dynamic-%: %.c
82         g++ -O2 -Wall -o $@ $<
83         strip $@
84
85 haskell/null-single: haskell/null.hs
86         ghc --make -O2 -Wall -o $@ $<
87         strip $@
88
89 haskell/null-threaded: haskell/null.hs
90         ghc --make -O2 -Wall -threaded -o $@ $<
91         strip $@
92
93 ocaml/null-byte: ocaml/null.ml
94         ocamlc -o $@ $<
95         # no stripping as this is not an elf file
96
97 ocaml/null-opt: ocaml/null.ml
98         ocamlopt -o $@ $<
99         strip $@
100
101 java/null-gcj-%: java/Null.java
102         gcj-$* --main=Null -o $@ $<
103         strip $@
104
105 java/Null.class: java/Null.java Makefile
106         javac $<
107
108 log: $(PROGS) $(SCRIPTS) java/Null.class Makefile
109         @rm -f log; \
110         for prog in $(ALL_TARGETS); do \
111           echo $$prog; \
112           for metric in $(METRICS); do \
113             LC_ALL=C $(PERF) stat -e "$$metric" -r $(REPS) -o log --append $$prog; \
114           done; \
115         done
116
117 test: $(PROGS) $(SCRIPTS) java/Null.class Makefile
118         @for prog in $(ALL_TARGETS); do \
119           echo $$prog; \
120           $$prog; \
121         done
122
123 clean:
124         cd asm && rm -f *.o
125         cd haskell && rm -f *.hi *.o
126         cd ocaml && rm -f *.cmo *.cmi *.cmx *.o
127         cd java && rm -f *.class
128         rm -f $(PROGS)
129
130 report:
131         LC_ALL=en_US.UTF-8 awk -f dump.awk log
132
133 .PHONY: log clean report test