From 0b94b2bfa5b2aa284156d39d798d300949425b1f Mon Sep 17 00:00:00 2001 From: Taylan Kammer Date: Fri, 28 Feb 2025 22:02:39 +0100 Subject: add parse bench --- src/libzisp.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libzisp.zig b/src/libzisp.zig index b2c8283..1a4789d 100644 --- a/src/libzisp.zig +++ b/src/libzisp.zig @@ -298,6 +298,18 @@ test "parse4" { try std.testing.expectEqualStrings("bar", f.slice()); } +test "parse bench" { + var timer = try std.time.Timer.start(); + std.mem.doNotOptimizeAway(timer.lap()); + for (0..1000) |i| { + _ = i; + std.mem.doNotOptimizeAway(io.parser.parse("(a b c (x y z (a b c (x y z (a b c (x y z (a b c (x y z (a b c (x y z (a b c (x y z (a b c (x y z) d e f) d e f) d e f) d e f) d e f) d e f) d e f) d e f) d e f) d e f) d e f) 1 2 3))")); + } + const ns: f64 = @floatFromInt(timer.lap()); + const secs = ns / 1_000_000_000; + std.debug.print("parse: {d:.3}s\n", .{secs}); +} + test "unparse" { const unparse = io.unparser.unparse; -- cgit v1.2.3