-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathMakefile
More file actions
185 lines (160 loc) Β· 5.64 KB
/
Makefile
File metadata and controls
185 lines (160 loc) Β· 5.64 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
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
#!/usr/bin/make -f
# Makefile for GraphServer Routing Profiler
# Builds and runs performance profiling for core routing algorithm
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -O2 -g -DNDEBUG
PROFILE_FLAGS = -pg -fprofile-arcs -ftest-coverage
LDFLAGS = -lm -lrt -lpthread
# Paths
CORE_DIR = ../core
BUILD_DIR = ../core/build
EXAMPLES_DIR = ../examples
SCRIPT_DIR = .
# Include directories
INCLUDES = -I$(CORE_DIR)/include -I$(EXAMPLES_DIR)/include
# Core library
CORE_LIB = $(BUILD_DIR)/libgraphserver_core.a
# Example providers object files
PROVIDER_SOURCES = $(EXAMPLES_DIR)/providers/utility_functions.c \
$(EXAMPLES_DIR)/providers/walking_provider.c \
$(EXAMPLES_DIR)/providers/transit_provider.c \
$(EXAMPLES_DIR)/providers/road_network_provider.c
PROVIDER_OBJECTS = $(PROVIDER_SOURCES:.c=.o)
# Profiler executable
PROFILER_TARGET = profile_routing
GPROF_TARGET = profile_routing_gprof
.PHONY: all clean profile gprof help build-core
all: $(PROFILER_TARGET)
help:
@echo "GraphServer Routing Profiler Build System"
@echo "==========================================="
@echo ""
@echo "Targets:"
@echo " all - Build standard profiler (default)"
@echo " profile - Build and run profiler with default scenarios"
@echo " profile-25 - Run profiler with 25 scenarios (recommended)"
@echo " profile-50 - Run profiler with 50 scenarios (intensive)"
@echo " gprof - Build with gprof profiling and run"
@echo " clean - Remove built files"
@echo " help - Show this help"
@echo ""
@echo "Requirements:"
@echo " - Core library must be built first (run 'make build-core')"
@echo " - GCC with C99 support"
@echo ""
@echo "Usage Examples:"
@echo " make profile # Run with default settings"
@echo " make profile-25 # Run 25 routing scenarios"
@echo " make gprof # Generate gprof profile data"
# Ensure core library is built
build-core:
@echo "ποΈ Building core GraphServer library..."
@if [ ! -d "$(BUILD_DIR)" ]; then \
mkdir -p $(BUILD_DIR); \
cd $(BUILD_DIR) && cmake ..; \
fi
@cd $(BUILD_DIR) && make -j$$(nproc)
@echo "β
Core library built successfully"
# Build provider objects
$(PROVIDER_OBJECTS): %.o: %.c
@echo "π§ Compiling provider: $<"
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Standard profiler build
$(PROFILER_TARGET): build-core $(PROVIDER_OBJECTS) $(SCRIPT_DIR)/profile_routing.c
@echo "π¨ Building routing profiler..."
$(CC) $(CFLAGS) $(INCLUDES) \
$(SCRIPT_DIR)/profile_routing.c \
$(PROVIDER_OBJECTS) \
$(CORE_LIB) \
$(LDFLAGS) \
-o $(PROFILER_TARGET)
@echo "β
Profiler built successfully: ./$(PROFILER_TARGET)"
# gprof-enabled build
$(GPROF_TARGET): build-core $(PROVIDER_OBJECTS) $(SCRIPT_DIR)/profile_routing.c
@echo "π¨ Building gprof-enabled profiler..."
$(CC) $(CFLAGS) $(PROFILE_FLAGS) $(INCLUDES) \
$(SCRIPT_DIR)/profile_routing.c \
$(PROVIDER_OBJECTS) \
$(CORE_LIB) \
$(LDFLAGS) \
-o $(GPROF_TARGET)
@echo "β
gprof profiler built successfully: ./$(GPROF_TARGET)"
# Run profiler with default settings
profile: $(PROFILER_TARGET)
@echo ""
@echo "π Running GraphServer Routing Profiler"
@echo "========================================"
@echo ""
./$(PROFILER_TARGET)
# Run with specific scenario counts
profile-25: $(PROFILER_TARGET)
@echo ""
@echo "π Running Routing Profiler - 25 Scenarios"
@echo "==========================================="
@echo ""
./$(PROFILER_TARGET) 25
profile-50: $(PROFILER_TARGET)
@echo ""
@echo "π Running Routing Profiler - 50 Scenarios (Intensive)"
@echo "====================================================="
@echo ""
./$(PROFILER_TARGET) 50
profile-stress: $(PROFILER_TARGET)
@echo ""
@echo "π₯ Running Routing Profiler - Stress Test (100 scenarios)"
@echo "========================================================"
@echo ""
./$(PROFILER_TARGET) 100
# Run gprof profiling
gprof: $(GPROF_TARGET)
@echo ""
@echo "π¬ Running gprof profiling analysis"
@echo "===================================="
@echo ""
./$(GPROF_TARGET) 25
@if [ -f gmon.out ]; then \
echo ""; \
echo "π Generating gprof report..."; \
gprof $(GPROF_TARGET) gmon.out > gprof_report.txt; \
echo "β
gprof report saved to: gprof_report.txt"; \
echo ""; \
echo "π― Top functions by execution time:"; \
head -30 gprof_report.txt | tail -20; \
else \
echo "β No gprof data generated (gmon.out not found)"; \
fi
# Valgrind memory profiling
valgrind: $(PROFILER_TARGET)
@echo ""
@echo "π§ Running Valgrind memory profiling"
@echo "===================================="
@echo ""
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./$(PROFILER_TARGET) 10
@echo ""
@echo "β
Valgrind profile saved to: callgrind.out"
@echo " View with: kcachegrind callgrind.out"
# Performance comparison
compare: $(PROFILER_TARGET)
@echo ""
@echo "βοΈ Running performance comparison tests"
@echo "======================================="
@echo ""
@echo "Testing 10 scenarios..."
@time ./$(PROFILER_TARGET) 10
@echo ""
@echo "Testing 25 scenarios..."
@time ./$(PROFILER_TARGET) 25
# Clean build artifacts
clean:
@echo "π§Ή Cleaning build artifacts..."
rm -f $(PROFILER_TARGET) $(GPROF_TARGET)
rm -f $(PROVIDER_OBJECTS)
rm -f gmon.out gprof_report.txt callgrind.out
rm -f *.gcda *.gcno *.gcov
@echo "β
Clean completed"
# Install profiler to system (optional)
install: $(PROFILER_TARGET)
@echo "π¦ Installing profiler to /usr/local/bin..."
sudo cp $(PROFILER_TARGET) /usr/local/bin/graphserver-profile-routing
@echo "β
Installed as: graphserver-profile-routing"
.PHONY: profile profile-25 profile-50 profile-stress gprof valgrind compare install