Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

Make file copy benchmark standalone

Melb0af707fe0a6
diff --git a/build/tests.zig b/build/tests.zig
index f1761d3..f38925e 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -388,17 +388,38 @@ pub fn addZig(ctx: Context, session: Session) ZigTests {
"Benchmark transfer progress, tree aggregation and concurrent job polling",
).dependOn(&run_transfer_bench.step);
- // Benchmark the real JobRunner filesystem copy path independently from
- // progress-model measurements and normal unit tests.
- const copy_bench_tests = b.addTest(.{
- .root_module = files_tests.root_module,
- .filters = &.{"production copy benchmark"},
+ // Standalone executable for end-to-end measurements of the production
+ // JobRunner filesystem copy path.
+ const copy_bench_module = b.createModule(.{
+ .root_source_file = b.path("src/files/copy_bench.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ });
+ copy_bench_module.addImport("platform", ctx.platform_mod);
+ copy_bench_module.addImport("i18n", ctx.i18n_mod);
+ copy_bench_module.addImport("c", ctx.c.libc);
+ copy_bench_module.addImport("c_gfx", ctx.c.gfx);
+ copy_bench_module.addImport("c_archive", ctx.c.archive);
+ copy_bench_module.linkSystemLibrary("libarchive", .{});
+
+ const copy_bench_exe = b.addExecutable(.{
+ .name = "rediwm-copy-bench",
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("src/files/copy_bench_main.zig"),
+ .target = target,
+ .optimize = optimize,
+ .link_libc = true,
+ }),
+ .use_llvm = use_llvm,
+ .use_lld = use_llvm,
});
- const run_copy_bench = b.addRunArtifact(copy_bench_tests);
+ copy_bench_exe.root_module.addImport("copy_bench", copy_bench_module);
+ const run_copy_bench = b.addRunArtifact(copy_bench_exe);
run_copy_bench.has_side_effects = true;
b.step(
"bench-files-copy",
- "Benchmark production JobRunner filesystem copy throughput",
+ "Run the standalone production filesystem copy benchmark",
).dependOn(&run_copy_bench.step);
const terminal_integration = b.addSystemCommand(&.{"env"});
diff --git a/src/files/copy_bench.zig b/src/files/copy_bench.zig
index 7b728e7..e588bda 100644
--- a/src/files/copy_bench.zig
+++ b/src/files/copy_bench.zig
@@ -407,8 +407,7 @@ fn benchmarkProfile(
emitRow(profile, stats, &samples);
}
-test "production copy benchmark emits measurements" {
- const allocator = std.testing.allocator;
+pub fn run(allocator: Allocator) !void {
const configured_root = c.getenv("REDIWM_COPY_BENCH_DIR");
const base_path = if (configured_root) |path|
std.mem.span(path)
diff --git a/src/files/copy_bench_main.zig b/src/files/copy_bench_main.zig
new file mode 100644
index 0000000..54c3a10
--- /dev/null
+++ b/src/files/copy_bench_main.zig
@@ -0,0 +1,6 @@
+const std = @import("std");
+const copy_bench = @import("copy_bench");
+
+pub fn main() !void {
+ try copy_bench.run(std.heap.page_allocator);
+}
diff --git a/src/files_tests.zig b/src/files_tests.zig
index 0f223d5..b634191 100644
--- a/src/files_tests.zig
+++ b/src/files_tests.zig
@@ -6,13 +6,11 @@ const ops_mod = @import("files/ops.zig");
const clipboard_mod = @import("files/clipboard.zig");
const dirsize_mod = @import("files/dirsize.zig");
const transfer_bench_mod = @import("files/transfer_bench.zig");
-const copy_bench_mod = @import("files/copy_bench.zig");
const c = @import("files/c.zig").api;
const linux = std.os.linux;
test {
_ = transfer_bench_mod;
- _ = copy_bench_mod;
}
test "History navigation stack" {