Skip to content

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

Make Files benchmarks opt-in

Mel260af919ccd7
diff --git a/TESTING.md b/TESTING.md
index 0b7974b..65c3a44 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -8,6 +8,13 @@ zig build test
python3 tests/<name>.py
```
+The long-running Files benchmarks are skipped by default. To include the
+transfer and end-to-end copy benchmarks in the full test run, use:
+
+```sh
+REDIWM_RUN_BENCHMARKS=1 zig build test
+```
+
`zig build test-wlroots` checks the complete exported wlroots API against the
installed headers and tests embedded input-device lifecycles; it is included
in `zig build test`.
diff --git a/build/tests.zig b/build/tests.zig
index f38925e..f8eefce 100644
--- a/build/tests.zig
+++ b/build/tests.zig
@@ -30,6 +30,12 @@ pub const ZigTests = struct {
/// (tests/*.py) with their `test-*` steps.
pub fn addZig(ctx: Context, session: Session) ZigTests {
const b = ctx.b;
+ const run_files_benchmarks = if (b.graph.environ_map.get(
+ "REDIWM_RUN_BENCHMARKS",
+ )) |value|
+ std.mem.eql(u8, value, "1")
+ else
+ false;
const target = ctx.target;
const optimize = ctx.optimize;
const use_llvm = ctx.use_llvm;
@@ -422,6 +428,10 @@ pub fn addZig(ctx: Context, session: Session) ZigTests {
"Run the standalone production filesystem copy benchmark",
).dependOn(&run_copy_bench.step);
+ if (run_files_benchmarks) {
+ test_step.dependOn(&run_copy_bench.step);
+ }
+
const terminal_integration = b.addSystemCommand(&.{"env"});
terminal_integration.addPrefixedDirectoryArg("REDIWM_TEST_BIN=", support.installed(.bin, ""));
terminal_integration.addArg("python3");
diff --git a/src/files/transfer_bench.zig b/src/files/transfer_bench.zig
index 155393c..d423bc4 100644
--- a/src/files/transfer_bench.zig
+++ b/src/files/transfer_bench.zig
@@ -9,6 +9,8 @@ const projection = @import("transfer_tree.zig");
const tree_state = @import("app_transfer_tree.zig");
const Allocator = std.mem.Allocator;
+extern "c" fn getenv(name: [*:0]const u8) ?[*:0]const u8;
+
const benchmark_iterations = 5;
const concurrent_iterations = 3;
const concurrent_polls_per_thread = 10;
@@ -468,6 +470,11 @@ fn benchmarkConcurrentJobs(allocator: Allocator, job_count: usize) !void {
test "transfer benchmark emits workload measurements" {
const allocator = std.testing.allocator;
+ const enabled = getenv("REDIWM_RUN_BENCHMARKS") orelse
+ return error.SkipZigTest;
+ if (!std.mem.eql(u8, std.mem.span(enabled), "1")) {
+ return error.SkipZigTest;
+ }
std.debug.print(
"BENCH,phase,operation,profile,files,directories,jobs,polling_threads,worker_count,iterations,median_ns,min_ns,max_ns,operations_per_second\n",