diff options
Diffstat (limited to 'test/pdf_bench.zig')
| -rw-r--r-- | test/pdf_bench.zig | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/test/pdf_bench.zig b/test/pdf_bench.zig index fb911bee..0f09f72a 100644 --- a/test/pdf_bench.zig +++ b/test/pdf_bench.zig @@ -470,6 +470,8 @@ fn mib(bytes: u64) f64 { return @as(f64, @floatFromInt(bytes)) / (1024.0 * 1024.0); } +const report_max_bytes = 64 * 1024; + fn reportText( io: std.Io, config: Config, @@ -477,10 +479,9 @@ fn reportText( multi_pages: usize, results: []const Result, ) void { - var out: std.ArrayList(u8) = .empty; - defer out.deinit(gpa); + var storage: [report_max_bytes]u8 = undefined; + var out: std.Io.Writer = .fixed(&storage); out.print( - gpa, "pardes PDF render benchmark (ReleaseFast)\n" ++ "path: {s} ({d} pages), selected page: {d}, multi-page pass: {d} pages\n" ++ "warmup: {d}, sampled reps: {d}; cold = fresh Document (OS cache uncontrolled)\n" ++ @@ -500,8 +501,7 @@ fn reportText( tint_colors.foreground[2], }, ) catch return; - out.appendSlice( - gpa, + out.writeAll( "profile scenario min ms median p90 max ms MPix/s GiB/s pixels/op RGBA MiB checksum\n" ++ "-----------------------------------------------------------------------------------------------------------------------------------\n", ) catch return; @@ -509,7 +509,6 @@ fn reportText( const profile = profiles[result.profile]; const scenario = scenarios[result.scenario]; out.print( - gpa, "{s:<20} {s:<26} {d:>8.2} {d:>8.2} {d:>8.2} {d:>8.2} {d:>7.1} {d:>6.2} {d:>10} {d:>9.2} {x:0>16}\n", .{ profile.id, @@ -526,10 +525,9 @@ fn reportText( }, ) catch return; } - out.appendSlice(gpa, "\nrequests:\n") catch return; + out.writeAll("\nrequests:\n") catch return; for (profiles) |profile| { out.print( - gpa, " {s}: dpi={d}, viewport-min={d}x{d}, max-dimension={d} — {s}\n", .{ profile.id, @@ -541,7 +539,7 @@ fn reportText( }, ) catch return; } - std.Io.File.stdout().writeStreamingAll(io, out.items) catch {}; + std.Io.File.stdout().writeStreamingAll(io, out.buffered()) catch {}; } fn reportJson( @@ -551,12 +549,11 @@ fn reportJson( multi_pages: usize, results: []const Result, ) void { - var out: std.ArrayList(u8) = .empty; - defer out.deinit(gpa); + var storage: [report_max_bytes]u8 = undefined; + var out: std.Io.Writer = .fixed(&storage); const path_json = std.json.Stringify.valueAlloc(gpa, config.path, .{}) catch return; defer gpa.free(path_json); out.print( - gpa, "{{\"benchmark\":\"pardes-pdf-render\",\"build\":\"ReleaseFast\"," ++ "\"path\":{s},\"document_pages\":{d},\"selected_page\":{d}," ++ "\"multi_pages\":{d},\"warmup\":{d},\"reps\":{d}," ++ @@ -579,7 +576,6 @@ fn reportJson( ) catch return; for (profiles, 0..) |profile, i| { out.print( - gpa, "{s}{{\"id\":\"{s}\",\"dpi\":{d},\"minimum_width\":{d}," ++ "\"minimum_height\":{d},\"max_dimension\":{d}}}", .{ @@ -592,10 +588,9 @@ fn reportJson( }, ) catch return; } - out.appendSlice(gpa, "],\"results\":[") catch return; + out.writeAll("],\"results\":[") catch return; for (results, 0..) |result, i| { out.print( - gpa, "{s}{{\"profile\":\"{s}\",\"scenario\":\"{s}\"," ++ "\"min_ns\":{d},\"median_ns\":{d},\"p90_ns\":{d}," ++ "\"max_ns\":{d},\"sampled_ns\":{d},\"pixels\":{d}," ++ @@ -618,8 +613,8 @@ fn reportJson( }, ) catch return; } - out.appendSlice(gpa, "]}\n") catch return; - std.Io.File.stdout().writeStreamingAll(io, out.items) catch {}; + out.writeAll("]}\n") catch return; + std.Io.File.stdout().writeStreamingAll(io, out.buffered()) catch {}; } fn fatal(comptime format: []const u8, args: anytype) noreturn { |
