-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile.txt
More file actions
72 lines (59 loc) · 2.3 KB
/
Copy pathmakefile.txt
File metadata and controls
72 lines (59 loc) · 2.3 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
CXX = g++
CXXFLAGS = -std=c++17 -O3 -Wall -Wextra -pedantic
DEBUG_FLAGS = -g -DDEBUG
TARGETS = orderbook_processor stream_generator
BUILD_DIR = build
.PHONY: all clean test debug benchmark
all: $(BUILD_DIR) $(addprefix $(BUILD_DIR)/, $(TARGETS))
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/orderbook_processor: orderbook_processor.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
$(BUILD_DIR)/stream_generator: stream_generator.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
debug: CXXFLAGS += $(DEBUG_FLAGS)
debug: clean all
clean:
rm -rf $(BUILD_DIR)
# Generate test files
test-data: all
@echo "Generating test data files..."
@$(BUILD_DIR)/stream_generator $(BUILD_DIR)/input1.bin
@$(BUILD_DIR)/stream_generator $(BUILD_DIR)/large_1mb.bin 1
@$(BUILD_DIR)/stream_generator $(BUILD_DIR)/large_2mb.bin 2
@echo "Test data generated in $(BUILD_DIR)/"
# Run basic test
test: all test-data
@echo "Running basic test..."
@cat $(BUILD_DIR)/input1.bin | $(BUILD_DIR)/orderbook_processor 5
@echo "\nTest completed!"
# Run benchmark tests
benchmark: all test-data
@echo "=== Benchmark Tests ==="
@echo "\n1MB file (depth=5):"
@time cat $(BUILD_DIR)/large_1mb.bin | $(BUILD_DIR)/orderbook_processor 5 > /dev/null
@echo "\n2MB file (depth=10):"
@time cat $(BUILD_DIR)/large_2mb.bin | $(BUILD_DIR)/orderbook_processor 10 > /dev/null
@echo "\n2MB file (depth=20):"
@time cat $(BUILD_DIR)/large_2mb.bin | $(BUILD_DIR)/orderbook_processor 20 > /dev/null
# Validate output against expected
validate: all test-data
@echo "Validating output..."
@cat $(BUILD_DIR)/input1.bin | $(BUILD_DIR)/orderbook_processor 5 > $(BUILD_DIR)/actual.log
@if diff -w output1.log $(BUILD_DIR)/actual.log > /dev/null 2>&1; then \
echo "✓ Output matches expected!"; \
else \
echo "✗ Output differs from expected"; \
diff -w output1.log $(BUILD_DIR)/actual.log; \
fi
# Help target
help:
@echo "Available targets:"
@echo " make - Build all executables"
@echo " make clean - Remove build directory"
@echo " make test - Generate test data and run basic test"
@echo " make test-data - Generate test stream files"
@echo " make benchmark - Run performance benchmarks"
@echo " make validate - Validate output against expected"
@echo " make debug - Build with debug symbols"
@echo " make help - Show this help message"