-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (34 loc) · 1.04 KB
/
Copy pathMakefile
File metadata and controls
50 lines (34 loc) · 1.04 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
CXX := g++
CXXFLAGS := -std=c++20 -O3 -DNDEBUG -march=native -mtune=native -pipe -pthread
INCLUDES := -Iinclude
LIB_SRC := src/level.cpp src/order_book.cpp src/order_pool.cpp
LIB_OBJ := $(LIB_SRC:src/%.cpp=build/%.o)
LIB := build/liborderbook.a
BENCH_SRC := bench/main.cpp
BENCH_OBJ := build/main.o
BENCH := orderbook
PERF_EVENTS := cycles,instructions,cache-references,cache-misses,branches,branch-misses
# Default: build the bench binary and run perf counters on it
all: perf
# Library
$(LIB): $(LIB_OBJ)
ar rcs $@ $^
build/%.o: src/%.cpp
@mkdir -p build
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Bench
$(BENCH_OBJ): $(BENCH_SRC)
@mkdir -p build
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(BENCH): $(BENCH_OBJ) $(LIB)
$(CXX) $(CXXFLAGS) $(BENCH_OBJ) $(LIB) -o $@
# Convenience
lib: $(LIB)
run: $(BENCH)
./$(BENCH)
perf: $(BENCH)
@command -v perf >/dev/null 2>&1 || { echo "perf is not installed. Run: make run"; exit 1; }
perf stat -e $(PERF_EVENTS) ./$(BENCH)
clean:
rm -rf build $(BENCH)
.PHONY: all lib run perf clean