forked from hrbrmstr/tdigest
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
182 lines (148 loc) · 5.31 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#----------------------------------------------------------------------------------------------------
# simple Makefile for T-Digest, relies on cmake to do the actual build.
# Use CMAKE_LIBRARY_OPTIONS,CMAKE_LIBRARY_SHARED_OPTIONS,CMAKE_LIBRARY_STATIC_OPTIONS or CMAKE_FULL_OPTIONS argument to this Makefile to pass options to cmake.
#----------------------------------------------------------------------------------------------------
CC?=gcc
INFER?=./deps/infer
INFER_DOCKER?=redisbench/infer-linux64:1.0.0
ROOT=$(shell pwd)
SRCDIR := $(ROOT)/src
TESTDIR := $(ROOT)/tests/unit
BENCHDIR := $(ROOT)/tests/benchmark
ifndef CMAKE_LIBRARY_SHARED_OPTIONS
CMAKE_LIBRARY_SHARED_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
endif
ifndef CMAKE_LIBRARY_STATIC_OPTIONS
CMAKE_LIBRARY_STATIC_OPTIONS=\
-DBUILD_SHARED=OFF \
-DBUILD_STATIC=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
endif
ifndef CMAKE_LIBRARY_OPTIONS
CMAKE_LIBRARY_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ON \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF
endif
ifndef CMAKE_FULL_OPTIONS
CMAKE_FULL_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ON \
-DBUILD_TESTS=ON \
-DBUILD_BENCHMARK=ON \
-DBUILD_EXAMPLES=ON
endif
ifndef CMAKE_PROFILE_OPTIONS
CMAKE_PROFILE_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=ON \
-DBUILD_EXAMPLES=OFF \
-DENABLE_PROFILE=ON
endif
ifndef CMAKE_SANITIZE_OPTIONS
CMAKE_SANITIZE_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=ON \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF \
-DENABLE_PROFILE=OFF \
-DENABLE_SANITIZERS=ON
endif
ifndef CMAKE_TEST_OPTIONS
CMAKE_TEST_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ON \
-DBUILD_TESTS=ON \
-DENABLE_CODECOVERAGE=ON \
-DBUILD_BENCHMARK=OFF \
-DBUILD_EXAMPLES=OFF
endif
ifndef CMAKE_BENCHMARK_OPTIONS
CMAKE_BENCHMARK_OPTIONS=\
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DENABLE_CODECOVERAGE=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCHMARK=ON \
-DBUILD_EXAMPLES=OFF \
-DENABLE_PROFILE=OFF
endif
default: full
# just build the static library. Do not build tests or benchmarks
library_static:
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_STATIC_OPTIONS) .. ; $(MAKE) )
# just build the shared library. Do not build tests or benchmarks
library_shared:
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_SHARED_OPTIONS) .. ; $(MAKE) )
# just build the static and shared libraries. Do not build tests or benchmarks
library_all:
( mkdir -p build; cd build ; cmake $(CMAKE_LIBRARY_OPTIONS) .. ; $(MAKE) )
# just build the static and shared libraries and produce measurements
# of accuracy versus compression factor for fixed data size
# TODO:
# just build the static and shared libraries and tests
unit_tests:
( mkdir -p build; cd build ; cmake $(CMAKE_TEST_OPTIONS) .. ; $(MAKE) ; $(MAKE) test)
test:
$(MAKE) unit_tests
coverage:
( mkdir -p build; cd build ; cmake $(CMAKE_TEST_OPTIONS) .. ; $(MAKE) ; $(MAKE) test; make coverage; )
format:
clang-format -style=file -i $(SRCDIR)/*.c
clang-format -style=file -i $(SRCDIR)/*.h
clang-format -style=file -i $(TESTDIR)/*.c
clang-format -style=file -i $(TESTDIR)/*.h
clang-format -style=file -i $(BENCHDIR)/*.cpp
lint:
clang-format -style=file -Werror -n $(SRCDIR)/*.c
clang-format -style=file -Werror -n $(SRCDIR)/*.h
clang-format -style=file -Werror -n $(TESTDIR)/*.c
clang-format -style=file -Werror -n $(TESTDIR)/*.h
clang-format -style=file -Werror -n $(BENCHDIR)/*.cpp
# build all
full:
( mkdir -p build; cd build ; cmake $(CMAKE_FULL_OPTIONS) .. ; $(MAKE) )
# static-analysis-docker:
# $(MAKE) clean
# docker run -v $(ROOT)/:/t-digest-c/ --user "$(username):$(usergroup)" $(INFER_DOCKER) bash -c "cd t-digest-c && CC=clang infer run --keep-going --fail-on-issue --biabduction -- make test"
clean: distclean
distclean:
rm -rf build/*
sanitize: clean
( mkdir -p build; cd build ; cmake $(CMAKE_SANITIZE_OPTIONS) .. ; $(MAKE) VERBOSE=1 )
$(SHOW) build/tests/td_test
profile: clean
( mkdir -p build; cd build ; cmake $(CMAKE_PROFILE_OPTIONS) .. ; $(MAKE) VERBOSE=1 2> $(basename $@).compiler_stedrr_output.txt )
bench: clean
( mkdir -p build; cd build ; cmake $(CMAKE_BENCHMARK_OPTIONS) .. ; $(MAKE) VERBOSE=1 )
$(SHOW) build/tests/histogram_benchmark --benchmark_min_time=5 --benchmark_out=results.json --benchmark_out_format=json
bench-quantile: clean
( mkdir -p build; cd build ; cmake $(CMAKE_BENCHMARK_OPTIONS) .. ; $(MAKE) VERBOSE=1 )
$(SHOW) build/tests/histogram_benchmark --benchmark_min_time=5 --benchmark_filter="BM_td_quantile_lognormal_dist_given_array*|BM_td_quantiles_*"
perf-stat-bench:
( mkdir -p build; cd build ; cmake $(CMAKE_PROFILE_OPTIONS) .. ; $(MAKE) VERBOSE=1 )
$(SHOW) perf stat build/tests/histogram_benchmark --benchmark_min_time=10
perf-record-bench: clean
( mkdir -p build; cd build ; cmake $(CMAKE_PROFILE_OPTIONS) .. ; $(MAKE) VERBOSE=1 )
$(SHOW) perf record -g -o perf.data.td_add \
build/tests/histogram_benchmark
perf-report-bench:
$(SHOW) perf report -g "graph,0.5,caller" -i perf.data.td_add
perf-report-bench-pprof:
go tool pprof -web perf.data.td_add