From f3b62fe53b19e36f21f8020831718cbf095d6a7b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 3 Jul 2026 17:33:05 -0300 Subject: performance pass --- build.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index f2a691c3..bc9308c8 100644 --- a/build.zig +++ b/build.zig @@ -145,6 +145,7 @@ pub fn build(b: *std.Build) void { // You'll want to use a lazy dependency here so that ghostty is only // downloaded if you actually need it. + var ghostty_vt_for_tests: ?*std.Build.Module = null; if (b.lazyDependency("ghostty", .{ // Setting simd to false will force a pure static build that // doesn't even require libc, but it has a significant performance @@ -157,6 +158,7 @@ pub fn build(b: *std.Build) void { // own uucode into vaxis. We undo that below by overriding both imports // with ours — order matters, so this must happen after this point. const ghostty_vt = dep.module("ghostty-vt"); + ghostty_vt_for_tests = ghostty_vt; ghostty_vt.addImport("uucode", uucode_mod); if (is_emscripten) { const term_opts = b.addOptions(); @@ -517,6 +519,48 @@ pub fn build(b: *std.Build) void { const test_sdl_step = b.step("test-sdl", "run SDL3 GPU e2e tests (requires -Dsdl)"); test_sdl_step.dependOn(&run_sdl_tests.step); + const tty_perf = b.addExecutable(.{ + .name = "pardes-tty-edit-perf", + .linkage = exe_linkage, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("tests_tty_perf.zig"), + .link_libc = true, + }), + }); + if (ghostty_vt_for_tests) |ghostty_vt| tty_perf.root_module.addImport("ghostty-vt", ghostty_vt); + const run_tty_perf = b.addRunArtifact(tty_perf); + run_tty_perf.addArtifactArg(exe); + const tty_perf_step = b.step("perf-tty-edit", "measure text editing latency through the vaxis tty backend"); + if (sdl_backend) { + tty_perf_step.dependOn(&b.addFail("perf-tty-edit measures the terminal backend; run without -Dsdl and without an Emscripten target").step); + } else { + tty_perf_step.dependOn(&run_tty_perf.step); + } + + const syntax_perf = b.addExecutable(.{ + .name = "pardes-syntax-perf", + .linkage = exe_linkage, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("tests_syntax_perf.zig"), + .link_libc = true, + }), + }); + if (ghostty_vt_for_tests) |ghostty_vt| syntax_perf.root_module.addImport("ghostty-vt", ghostty_vt); + const run_syntax_perf = b.addRunArtifact(syntax_perf); + run_syntax_perf.addArtifactArg(exe); + const syntax_perf_step = b.step("perf-syntax", "measure highlighted file open/edit latency through the vaxis tty backend"); + if (sdl_backend) { + syntax_perf_step.dependOn(&b.addFail("perf-syntax measures the terminal backend; run without -Dsdl and without an Emscripten target").step); + } else if (!syntax_highlighting) { + syntax_perf_step.dependOn(&b.addFail("perf-syntax requires tree-sitter; run with -Dtree-sitter=minimal or -Dtree-sitter=full").step); + } else { + syntax_perf_step.dependOn(&run_syntax_perf.step); + } + // Unit tests for the pure modal-editing math (modal.zig has no vaxis/ghostty // deps, so `zig test` on it is fast and needs no wired-in modules). const unit_tests = b.addTest(.{ -- cgit v1.3