-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
320 lines (252 loc) · 12.6 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
clr_error := $(shell tty -s > /dev/null 2>&1 && tput setaf 1)
clr_comment := $(shell tty -s > /dev/null 2>&1 && tput setaf 2)
clr_info := $(shell tty -s > /dev/null 2>&1 && tput setaf 3)
clr_reset := $(shell tty -s > /dev/null 2>&1 && tput sgr0)
comma := ,
define help
$(clr_info)Usage:$(clr_reset)
make [target]
$(clr_info)Targets:$(clr_reset)
clean
$(clr_comment)Remove previously generated reports (if any)$(clr_reset)
bench-all
$(clr_comment)Run all benchmarks$(clr_reset)
bench-sync-connectors
$(clr_comment)Benchmark connectors in sync mode$(clr_reset)
bench-sync-client-packers
$(clr_comment)Benchmark client packers in sync mode$(clr_reset)
bench-sync-client-protocols
$(clr_comment)Benchmark binary/SQL protocols in sync mode$(clr_reset)
bench-async-coroutines
$(clr_comment)Benchmark connectors in async mode using $(clr_info)ext-async$(clr_comment) with different number of coroutines$(clr_reset)
bench-async-connectors
$(clr_comment)Benchmark connectors in async mode using $(clr_info)ext-async$(clr_reset)
bench-async-client-protocols
$(clr_comment)Benchmark binary/SQL protocols in async mode using $(clr_info)ext-async$(clr_reset)
bench-swoole-coroutines
$(clr_comment)Benchmark connectors in async mode using $(clr_info)ext-swoole$(clr_comment) with different number of coroutines$(clr_reset)
bench-swoole-connectors
$(clr_comment)Benchmark connectors in async mode using $(clr_info)ext-swoole$(clr_reset)
bench-swoole-client-protocols
$(clr_comment)Benchmark binary/SQL protocols in async mode using $(clr_info)ext-swoole$(clr_reset)
bench-parallel-threads
$(clr_comment)Benchmark connectors in parallel mode using $(clr_info)ext-parallel$(clr_comment) with different number of threads$(clr_reset)
bench-parallel-connectors
$(clr_comment)Benchmark connectors in parallel mode using $(clr_info)ext-parallel$(clr_reset)
bench-parallel-client-protocols
$(clr_comment)Benchmark binary/SQL protocols in parallel mode using $(clr_info)ext-parallel$(clr_reset)
bench-extensions
$(clr_comment)Benchmark pecl extensions$(clr_reset)
endef
define run_bench
cd benchmarks/$(1) && ../../vendor/bin/phpbench run ../$(2)Bench.php --dump-file=../../$@ --tag=$(subst reports/,,$(subst .xml,,$@)) $(phpbench_options) $(3) || true
endef
define make_report
cd benchmarks/$(1) && ../../vendor/bin/phpbench report --file=../../$(subst .xml ,.xml --file=../../,$^) --report=tag-table
cd benchmarks/$(1) && ../../vendor/bin/phpbench report --file=../../$(subst .xml ,.xml --file=../../,$^) --report=chart --output='extends: "chart-image", basename: "$(subst -,_,$(subst bench-,,$@))", "labels": {$(2)}'
endef
.PHONY: help
help:
@echo $(info $(help))
vendor:
@composer install
reports/%: TNT_BENCH_TARANTOOL_URI := $(if $(TNT_BENCH_TARANTOOL_URI),$(TNT_BENCH_TARANTOOL_URI),tcp://localhost:3301)
reports/%: TNT_BENCH_RETRY_THRESHOLD := $(if $(TNT_BENCH_RETRY_THRESHOLD),$(TNT_BENCH_RETRY_THRESHOLD),3)
reports/%: phpbench_options += $(if $(TNT_BENCH_ITERATIONS), --iterations=$(TNT_BENCH_ITERATIONS),)
reports/%: phpbench_options += $(if $(TNT_BENCH_REVOLUTIONS), --revs=$(TNT_BENCH_REVOLUTIONS),)
reports/%: phpbench_options += $(if $(TNT_BENCH_RETRY_THRESHOLD), --retry-threshold=$(TNT_BENCH_RETRY_THRESHOLD),)
.PHONY: clean
clean:
@find reports -type f -not -name '_*' -delete
.PHONY: bench-all
bench-all: \
bench-sync-connectors \
bench-sync-client-packers \
bench-sync-client-protocols \
bench-async-coroutines \
bench-async-connectors \
bench-async-client-protocols \
bench-swoole-coroutines \
bench-swoole-connectors \
bench-swoole-client-protocols \
bench-parallel-threads \
bench-parallel-connectors \
bench-parallel-client-protocols \
bench-extensions
# sync
reports/sync__tarantool.xml: vendor
@$(call run_bench,Sync,Tarantool)
reports/sync__client__packer_pecl.xml: vendor
@export TNT_BENCH_PACKER=pecl && $(call run_bench,Sync,Client)
reports/sync__client__packer_pure.xml: vendor
@export TNT_BENCH_PACKER=pure && $(call run_bench,Sync,Client)
reports/sync__client__packer_pecl__protocol_bin.xml: vendor
@export TNT_BENCH_PACKER=pecl && $(call run_bench,Sync,Client,--filter=select --filter=insert --filter=update --filter=delete)
reports/sync__client__packer_pecl__protocol_sql.xml: vendor
@export TNT_BENCH_PACKER=pecl && $(call run_bench,Sync,ClientSql,--filter=select --filter=insert --filter=update --filter=delete)
.PHONY: bench-sync-connectors
bench-sync-connectors: \
reports/sync__tarantool.xml \
reports/sync__client__packer_pecl.xml
@$(call make_report,Sync, \
"sync__tarantool": "Tarantool"$(comma) \
"sync__client__packer_pecl": "Client (pecl packer)" \
)
.PHONY: bench-sync-client-packers
bench-sync-client-packers: \
reports/sync__client__packer_pecl.xml \
reports/sync__client__packer_pure.xml
@$(call make_report,Sync, \
"sync__client__packer_pecl": "Pecl"$(comma) \
"sync__client__packer_pure": "Pure" \
)
.PHONY: bench-sync-client-protocols
bench-sync-client-protocols: \
reports/sync__client__packer_pecl__protocol_bin.xml \
reports/sync__client__packer_pecl__protocol_sql.xml
@$(call make_report,Sync, \
"sync__client__packer_pecl__protocol_bin": "Binary"$(comma) \
"sync__client__packer_pecl__protocol_sql": "Sql" \
)
# async
reports/async__tarantool__co%.xml: vendor
@export TNT_BENCH_COROUTINES=$* && $(call run_bench,Async,Tarantool)
reports/async__client__packer_pecl__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Async,Client)
reports/async__client__packer_pecl__protocol_bin__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Async,Client,--filter=select --filter=insert --filter=update --filter=delete)
reports/async__client__packer_pecl__protocol_sql__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Async,ClientSql,--filter=select --filter=insert --filter=update --filter=delete)
.PHONY: bench-async-coroutines
bench-async-coroutines: \
reports/async__client__packer_pecl__co10.xml \
reports/async__client__packer_pecl__co25.xml \
reports/async__client__packer_pecl__co50.xml \
reports/async__client__packer_pecl__co100.xml
@$(call make_report,Async, \
"async__client__packer_pecl__co10": "co10"$(comma) \
"async__client__packer_pecl__co25": "co25"$(comma) \
"async__client__packer_pecl__co50": "co50"$(comma) \
"async__client__packer_pecl__co100": "co100" \
)
.PHONY: bench-async-connectors
bench-async-connectors: \
reports/async__tarantool__co25.xml \
reports/async__client__packer_pecl__co25.xml
@$(call make_report,Async, \
"async__tarantool__co25": "Tarantool"$(comma) \
"async__client__packer_pecl__co25": "Client" \
)
.PHONY: bench-async-client-protocols
bench-async-client-protocols: \
reports/async__client__packer_pecl__protocol_bin__co25.xml \
reports/async__client__packer_pecl__protocol_sql__co25.xml
@$(call make_report,Async, \
"async__client__packer_pecl__protocol_bin__co25": "Binary"$(comma) \
"async__client__packer_pecl__protocol_sql__co25": "Sql" \
)
# swoole
reports/swoole__tarantool__co%.xml: vendor
@export TNT_BENCH_COROUTINES=$* && $(call run_bench,Swoole,Tarantool)
reports/swoole__client__packer_pecl__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Swoole,Client)
reports/swoole__client__packer_pecl__protocol_bin__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Swoole,Client,--filter=select --filter=insert --filter=update --filter=delete)
reports/swoole__client__packer_pecl__protocol_sql__co%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_COROUTINES=$* && $(call run_bench,Swoole,ClientSql,--filter=select --filter=insert --filter=update --filter=delete)
reports/swoole__tarantool__proc2__co25.xml: vendor
@export TNT_BENCH_TEMPLATE=proc_co.php.tpl TNT_BENCH_WORKERS=2 TNT_BENCH_COROUTINES=25 && $(call run_bench,Swoole,Tarantool)
reports/swoole__client__packer_pecl__proc2__co25.xml: vendor
@export TNT_BENCH_TEMPLATE=proc_co.php.tpl TNT_BENCH_PACKER=pecl TNT_BENCH_WORKERS=2 TNT_BENCH_COROUTINES=25 && $(call run_bench,Swoole,Client)
.PHONY: bench-swoole-coroutines
bench-swoole-coroutines: \
reports/swoole__client__packer_pecl__co10.xml \
reports/swoole__client__packer_pecl__co25.xml \
reports/swoole__client__packer_pecl__co50.xml \
reports/swoole__client__packer_pecl__co100.xml
@$(call make_report,Swoole, \
"swoole__client__packer_pecl__co10": "co10"$(comma) \
"swoole__client__packer_pecl__co25": "co25"$(comma) \
"swoole__client__packer_pecl__co50": "co50"$(comma) \
"swoole__client__packer_pecl__co100": "co100" \
)
.PHONY: bench-swoole-connectors
bench-swoole-connectors: \
reports/swoole__tarantool__co25.xml \
reports/swoole__tarantool__proc2__co25.xml \
reports/swoole__client__packer_pecl__co25.xml \
reports/swoole__client__packer_pecl__proc2__co25.xml
@$(call make_report,Swoole, \
"swoole__tarantool__co25": "Tarantool (co25)"$(comma) \
"swoole__tarantool__proc2__co25": "Tarantool (co25 proc2)"$(comma) \
"swoole__client__packer_pecl__co25": "Client (co25)"$(comma) \
"swoole__client__packer_pecl__proc2__co25": "Client (co25 proc2)" \
)
.PHONY: bench-swoole-client-protocols
bench-swoole-client-protocols: \
reports/swoole__client__packer_pecl__protocol_bin__co25.xml \
reports/swoole__client__packer_pecl__protocol_sql__co25.xml
@$(call make_report,Swoole, \
"swoole__client__packer_pecl__protocol_bin__co25": "Binary"$(comma) \
"swoole__client__packer_pecl__protocol_sql__co25": "Sql" \
)
# parallel
reports/parallel__tarantool__t%.xml: vendor
@export TNT_BENCH_WORKERS=$* && $(call run_bench,Parallel,Tarantool)
reports/parallel__client__packer_pecl__t%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_WORKERS=$* && $(call run_bench,Parallel,Client)
reports/parallel__client__packer_pecl__protocol_bin__t%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_WORKERS=$* && $(call run_bench,Parallel,Client,--filter=select --filter=insert --filter=update --filter=delete)
reports/parallel__client__packer_pecl__protocol_sql__t%.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_WORKERS=$* && $(call run_bench,Parallel,ClientSql,--filter=select --filter=insert --filter=update --filter=delete)
.PHONY: bench-parallel-threads
bench-parallel-threads: \
reports/parallel__client__packer_pecl__t2.xml \
reports/parallel__client__packer_pecl__t4.xml \
reports/parallel__client__packer_pecl__t8.xml \
reports/parallel__client__packer_pecl__t16.xml \
reports/parallel__client__packer_pecl__t32.xml
@$(call make_report,Parallel, \
"parallel__client__packer_pecl__t2": "t2"$(comma) \
"parallel__client__packer_pecl__t4": "t4"$(comma) \
"parallel__client__packer_pecl__t8": "t8"$(comma) \
"parallel__client__packer_pecl__t16": "t16"$(comma) \
"parallel__client__packer_pecl__t32": "t32" \
)
.PHONY: bench-parallel-connectors
bench-parallel-connectors: \
reports/parallel__tarantool__t16.xml \
reports/parallel__client__packer_pecl__t16.xml
@$(call make_report,Parallel, \
"parallel__tarantool__t16":"Tarantool"$(comma) \
"parallel__client__packer_pecl__t16":"Client" \
)
.PHONY: bench-parallel-client-protocols
bench-parallel-client-protocols: \
reports/parallel__client__packer_pecl__protocol_bin__t16.xml \
reports/parallel__client__packer_pecl__protocol_sql__t16.xml
@$(call make_report,Parallel, \
"parallel__client__packer_pecl__protocol_bin__t16": "Binary"$(comma) \
"parallel__client__packer_pecl__protocol_sql__t16": "Sql" \
)
# extensions
reports/parallel_with_async__client__packer_pecl__t2__co10.xml: vendor
@export TNT_BENCH_PACKER=pecl TNT_BENCH_WORKERS=2 TNT_BENCH_COROUTINES=10 && $(call run_bench,ParallelWithAsync,Client)
.PHONY: bench-extensions
bench-extensions: \
reports/async__client__packer_pecl__co25.xml \
reports/swoole__tarantool__co25.xml \
reports/swoole__tarantool__proc2__co25.xml \
reports/swoole__client__packer_pecl__proc2__co25.xml \
reports/parallel__tarantool__t16.xml \
reports/parallel__client__packer_pecl__t16.xml \
reports/parallel_with_async__client__packer_pecl__t2__co10.xml
@$(call make_report,Sync, \
"async__client__packer_pecl__co25": "Client (async)"$(comma) \
"swoole__tarantool__co25": "Tarantool (swoole)"$(comma) \
"swoole__tarantool__proc2__co25": "Tarantool (swoole 2 proc)"$(comma) \
"swoole__client__packer_pecl__proc2__co25": "Client (swoole 2 proc)"$(comma) \
"parallel__tarantool__t16": "Tarantool (parallel)"$(comma) \
"parallel__client__packer_pecl__t16": "Client (parallel)"$(comma) \
"parallel_with_async__client__packer_pecl__t2__co10": "Client (parallel+async)" \
)