-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (65 loc) · 3.69 KB
/
Makefile
File metadata and controls
85 lines (65 loc) · 3.69 KB
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
CC ?= cc
CXX ?= c++
CFLAGS = -Wall -Wextra -Wpedantic -std=c11 -O2
BENCHFLAGS = -O3 -march=native -std=c11 -fno-stack-protector -fno-asynchronous-unwind-tables
ARENA = -DJBIN_MAX_NODES='(1<<24)' \
-DJBIN_MAX_STRING='(256u*1024u*1024u)' \
-DJBIN_MAX_STRUCTURAL='(1<<25)' \
-D_POSIX_C_SOURCE=199309L
DATA = data/canada.json data/twitter.json data/citm_catalog.json data/large.json
all: test_runner
test_runner: test_runner.c jbin.c jbin.h
$(CC) $(CFLAGS) -o $@ test_runner.c jbin.c
bench: bench.c jbin.c jbin.h
$(CC) $(BENCHFLAGS) $(ARENA) -o $@ bench.c jbin.c -lm
bench-pgo: bench.c jbin.c jbin.h
$(CC) $(BENCHFLAGS) $(ARENA) -fprofile-generate -o bench bench.c jbin.c -lm
@echo "Training PGO profile..."
@for i in 1 2 3 4 5; do ./bench data/twitter.json data/citm_catalog.json >/dev/null; done
@./bench data/canada.json data/large.json >/dev/null 2>/dev/null || true
@for i in 1 2 3; do ./bench data/mesh.json >/dev/null 2>/dev/null || true; done
@for i in 1 2 3 4 5; do ./bench data/booleans.json data/truenull.json data/deep_nested.json >/dev/null; done
@for i in 1 2 3 4 5; do ./bench data/string_array.json data/escape_heavy.json >/dev/null; done
@for i in 1 2 3; do ./bench data/flat_kv.json data/instruments.json data/mixed_types.json >/dev/null; done
$(CC) $(BENCHFLAGS) $(ARENA) -fprofile-use -flto -o bench bench.c jbin.c -lm
@rm -f *.gcda
@echo "PGO build complete. Run: ./bench -n100"
bench-pgo-clang: bench.c jbin.c jbin.h
clang $(BENCHFLAGS) $(ARENA) -fprofile-generate -o bench bench.c jbin.c -lm
@echo "Training PGO profile (clang)..."
@for i in 1 2 3 4 5; do ./bench data/twitter.json data/citm_catalog.json >/dev/null; done
@./bench data/canada.json data/large.json >/dev/null 2>/dev/null || true
@for i in 1 2 3; do ./bench data/mesh.json >/dev/null 2>/dev/null || true; done
@for i in 1 2 3 4 5; do ./bench data/booleans.json data/truenull.json data/deep_nested.json >/dev/null; done
@for i in 1 2 3 4 5; do ./bench data/string_array.json data/escape_heavy.json >/dev/null; done
@for i in 1 2 3; do ./bench data/flat_kv.json data/instruments.json data/mixed_types.json >/dev/null; done
llvm-profdata merge -output=bench.profdata default_*.profraw
clang $(BENCHFLAGS) $(ARENA) -fprofile-use=bench.profdata -flto -o bench bench.c jbin.c -lm
@rm -f *.profraw bench.profdata
@echo "PGO build complete (clang). Run: ./bench -n100"
bench-simdjson: bench_simdjson.cpp simdjson/simdjson.h simdjson/simdjson.cpp
$(CXX) -O3 -march=native -o $@ bench_simdjson.cpp simdjson/simdjson.cpp
bench-yyjson: bench_yyjson.c yyjson/yyjson.h yyjson/yyjson.c
$(CC) $(BENCHFLAGS) -D_POSIX_C_SOURCE=199309L -o $@ bench_yyjson.c yyjson/yyjson.c -lm
bench-rapidjson: bench_rapidjson.cpp
$(CXX) -O3 -march=native -Irapidjson/include -o $@ bench_rapidjson.cpp
bench-cjson: bench_cjson.c cjson/cJSON.h cjson/cJSON.c
$(CC) $(BENCHFLAGS) -D_POSIX_C_SOURCE=199309L -o $@ bench_cjson.c cjson/cJSON.c -lm
bench-sajson: bench_sajson.cpp sajson/sajson.h
$(CXX) -O3 -march=native -o $@ bench_sajson.cpp
check: test_runner
./test_runner
check-v: test_runner
./test_runner -v
check-suite: test_runner | JSONTestSuite
./test_runner JSONTestSuite/test_parsing
check-suite-v: test_runner | JSONTestSuite
./test_runner -v JSONTestSuite/test_parsing
JSONTestSuite:
git clone --depth 1 https://github.com/nst/JSONTestSuite.git
freestanding-check: jbin.c jbin.h
$(CC) -std=c11 -ffreestanding -c -o /dev/null jbin.c
@echo "freestanding compilation OK"
clean:
rm -f test_runner bench bench-simdjson bench-yyjson bench-rapidjson bench-cjson bench-sajson *.o *.gcda *.profraw *.profdata
.PHONY: all check check-v check-suite check-suite-v freestanding-check clean bench-pgo bench-pgo-clang