-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
250 lines (206 loc) · 9.21 KB
/
build.zig
File metadata and controls
250 lines (206 loc) · 9.21 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
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Create a module for the benchmark library
const bench_module = b.createModule(.{
.root_source_file = b.path("src/bench.zig"),
});
// Create modules for advanced features
const export_module = b.createModule(.{
.root_source_file = b.path("src/export.zig"),
});
export_module.addImport("bench", bench_module);
const comparison_module = b.createModule(.{
.root_source_file = b.path("src/comparison.zig"),
});
comparison_module.addImport("bench", bench_module);
const memory_profiler_module = b.createModule(.{
.root_source_file = b.path("src/memory_profiler.zig"),
});
const ci_module = b.createModule(.{
.root_source_file = b.path("src/ci.zig"),
});
ci_module.addImport("bench", bench_module);
ci_module.addImport("comparison", comparison_module);
const flamegraph_module = b.createModule(.{
.root_source_file = b.path("src/flamegraph.zig"),
});
// Advanced Features - Phase 2 modules
const groups_module = b.createModule(.{
.root_source_file = b.path("src/groups.zig"),
});
groups_module.addImport("bench", bench_module);
const warmup_module = b.createModule(.{
.root_source_file = b.path("src/warmup.zig"),
});
warmup_module.addImport("bench", bench_module);
const outliers_module = b.createModule(.{
.root_source_file = b.path("src/outliers.zig"),
});
outliers_module.addImport("bench", bench_module);
const parameterized_module = b.createModule(.{
.root_source_file = b.path("src/parameterized.zig"),
});
parameterized_module.addImport("bench", bench_module);
const parallel_module = b.createModule(.{
.root_source_file = b.path("src/parallel.zig"),
});
parallel_module.addImport("bench", bench_module);
// Advanced Features - Phase 3 modules
const streaming_module = b.createModule(.{
.root_source_file = b.path("src/streaming.zig"),
});
streaming_module.addImport("bench", bench_module);
const ab_testing_module = b.createModule(.{
.root_source_file = b.path("src/ab_testing.zig"),
});
ab_testing_module.addImport("bench", bench_module);
const diff_module = b.createModule(.{
.root_source_file = b.path("src/diff.zig"),
});
diff_module.addImport("bench", bench_module);
const monitoring_module = b.createModule(.{
.root_source_file = b.path("src/monitoring.zig"),
});
monitoring_module.addImport("bench", bench_module);
const exporters_module = b.createModule(.{
.root_source_file = b.path("src/exporters.zig"),
});
exporters_module.addImport("bench", bench_module);
const profiling_module = b.createModule(.{
.root_source_file = b.path("src/profiling.zig"),
});
profiling_module.addImport("bench", bench_module);
// Example executables
const examples = [_]struct {
name: []const u8,
path: []const u8,
}{
.{ .name = "basic", .path = "examples/basic.zig" },
.{ .name = "async", .path = "examples/async.zig" },
.{ .name = "custom_options", .path = "examples/custom_options.zig" },
.{ .name = "filtering_baseline", .path = "examples/filtering_baseline.zig" },
.{ .name = "allocators", .path = "examples/allocators.zig" },
.{ .name = "advanced_features", .path = "examples/advanced_features.zig" },
.{ .name = "phase2_features", .path = "examples/phase2_features.zig" },
.{ .name = "phase3_features", .path = "examples/phase3_features.zig" },
};
inline for (examples) |example| {
const exe_module = b.createModule(.{
.root_source_file = b.path(example.path),
.target = target,
.optimize = optimize,
});
exe_module.addImport("bench", bench_module);
// Add advanced feature imports for advanced_features example
if (std.mem.eql(u8, example.name, "advanced_features")) {
exe_module.addImport("export", export_module);
exe_module.addImport("comparison", comparison_module);
exe_module.addImport("memory_profiler", memory_profiler_module);
exe_module.addImport("ci", ci_module);
exe_module.addImport("flamegraph", flamegraph_module);
}
// Add Phase 2 feature imports for phase2_features example
if (std.mem.eql(u8, example.name, "phase2_features")) {
exe_module.addImport("groups", groups_module);
exe_module.addImport("warmup", warmup_module);
exe_module.addImport("outliers", outliers_module);
exe_module.addImport("parameterized", parameterized_module);
exe_module.addImport("parallel", parallel_module);
}
// Add Phase 3 feature imports for phase3_features example
if (std.mem.eql(u8, example.name, "phase3_features")) {
exe_module.addImport("streaming", streaming_module);
exe_module.addImport("ab_testing", ab_testing_module);
exe_module.addImport("diff", diff_module);
exe_module.addImport("monitoring", monitoring_module);
exe_module.addImport("exporters", exporters_module);
exe_module.addImport("profiling", profiling_module);
}
const exe = b.addExecutable(.{
.name = example.name,
.root_module = exe_module,
});
const install_exe = b.addInstallArtifact(exe, .{});
const exe_step = b.step(example.name, b.fmt("Build {s} example", .{example.name}));
exe_step.dependOn(&install_exe.step);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(&install_exe.step);
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(b.fmt("run-{s}", .{example.name}), b.fmt("Run the {s} example", .{example.name}));
run_step.dependOn(&run_cmd.step);
}
// Default step builds all examples
const all_step = b.step("examples", "Build all examples");
inline for (examples) |example| {
const exe_module = b.createModule(.{
.root_source_file = b.path(example.path),
.target = target,
.optimize = optimize,
});
exe_module.addImport("bench", bench_module);
// Add advanced feature imports for advanced_features example
if (std.mem.eql(u8, example.name, "advanced_features")) {
exe_module.addImport("export", export_module);
exe_module.addImport("comparison", comparison_module);
exe_module.addImport("memory_profiler", memory_profiler_module);
exe_module.addImport("ci", ci_module);
exe_module.addImport("flamegraph", flamegraph_module);
}
// Add Phase 2 feature imports for phase2_features example
if (std.mem.eql(u8, example.name, "phase2_features")) {
exe_module.addImport("groups", groups_module);
exe_module.addImport("warmup", warmup_module);
exe_module.addImport("outliers", outliers_module);
exe_module.addImport("parameterized", parameterized_module);
exe_module.addImport("parallel", parallel_module);
}
// Add Phase 3 feature imports for phase3_features example
if (std.mem.eql(u8, example.name, "phase3_features")) {
exe_module.addImport("streaming", streaming_module);
exe_module.addImport("ab_testing", ab_testing_module);
exe_module.addImport("diff", diff_module);
exe_module.addImport("monitoring", monitoring_module);
exe_module.addImport("exporters", exporters_module);
exe_module.addImport("profiling", profiling_module);
}
const exe = b.addExecutable(.{
.name = example.name,
.root_module = exe_module,
});
const install_exe = b.addInstallArtifact(exe, .{});
all_step.dependOn(&install_exe.step);
}
// Unit tests
const test_module = b.createModule(.{
.root_source_file = b.path("src/bench.zig"),
.target = target,
.optimize = optimize,
});
const unit_tests = b.addTest(.{
.root_module = test_module,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
// Integration tests
const integration_test_module = b.createModule(.{
.root_source_file = b.path("tests/integration_test.zig"),
.target = target,
.optimize = optimize,
});
integration_test_module.addImport("bench", bench_module);
const integration_tests = b.addTest(.{
.root_module = integration_test_module,
});
const run_integration_tests = b.addRunArtifact(integration_tests);
// Test steps
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&run_unit_tests.step);
test_step.dependOn(&run_integration_tests.step);
const unit_test_step = b.step("test-unit", "Run unit tests only");
unit_test_step.dependOn(&run_unit_tests.step);
const integration_test_step = b.step("test-integration", "Run integration tests only");
integration_test_step.dependOn(&run_integration_tests.step);
}