/
Makefile
68 lines (60 loc) · 2.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright (C) 2014 Povilas Kanapickas <povilas@radix.lt>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# The programs are as follows:
#
# libc - Uses standard glibc printf
# libc_long - Uses standard glibc printf with precision of 40 decimal digits
# cf - Optimized printf
# null_libc - Same as 'libc', just with the actual 'printf' removed. Useful for
# estimation of how much the printf call itself costs
# null_cf - Similar to 'null_libc' except that the infrastructure of 'cf' is
# tested.
# cmp - Compares libc and cf results. Prints only when the formatted strings do
# not match
# The 'test' target runs 'libc', 'null_libc', 'cf' and 'null_cf', pipes the
# output to /dev/null and prints the amount of *user* time used by each
# program. Be sure to disable CPU frequency scaling before running this.
PROGRAMS=libc libc_long cf libcpp null_libc null_cf cmp
all: $(PROGRAMS)
SOURCES=test.cc cformat.h cformat.cc
CFLAGS=-O3 -fno-lto
# WANT_ASM= -masm=intel --save-temps
libc: $(SOURCES)
g++ $(CFLAGS) -DTEST_LIBC=1 cformat.cc test.cc -o libc
libc_long: $(SOURCES)
g++ $(CFLAGS) -DTEST_LIBC_LONG=1 cformat.cc test.cc -o libc_long
cf: $(SOURCES)
g++ $(CFLAGS) -DTEST_CF=1 $(WANT_ASM) cformat.cc test.cc -o cf
libcpp: $(SOURCES)
g++ $(CFLAGS) -DTEST_LIBCPP=1 cformat.cc test.cc -o libcpp
null_libc: $(SOURCES)
g++ $(CFLAGS) -DTEST_NULL_LIBC=1 cformat.cc test.cc -o null_libc
null_cf: $(SOURCES)
g++ $(CFLAGS) -DTEST_NULL_CF=1 cformat.cc test.cc -o null_cf
cmp: $(SOURCES)
g++ $(CFLAGS) -DTEST_CMP=1 cformat.cc test.cc -o cmp
clean:
rm -f $(PROGRAMS)
test: all
@time -f " cf time: %U " ./cf > /dev/null
@time -f " libc time: %U " ./libc > /dev/null
@time -f " libcpp time: %U " ./libcpp > /dev/null
@time -f " null_cf time: %U " ./null_cf > /dev/null
@time -f " null_libc time: %U " ./null_libc > /dev/null
testout: all
./cf > out.cf
./libc > out.libc
./libc_long > out.long