summaryrefslogtreecommitdiff
path: root/src/Store.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Store.zig')
-rw-r--r--src/Store.zig61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/Store.zig b/src/Store.zig
index 2bb9fcf0..547e7bd6 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -1133,64 +1133,3 @@ test "store: a closed pane comes back where it was, its rows from the pane that
}
const panes_mod = @import("panes.zig");
-
-test "zz store timings on a 90 MiB store (STORE_TIMES=<dir>)" {
- const dir_z = std.c.getenv("STORE_TIMES") orelse return error.SkipZigTest;
- const gpa = testing.allocator;
- const path = try std.fs.path.join(gpa, &.{ std.mem.span(dir_z), "store" });
- defer gpa.free(path);
- // A store as another running session leaves it: 200 files, then 90
- // closed panes of 1 MiB each (this pid: alive, so a compaction keeps
- // what fits).
- {
- var bytes: std.ArrayList(u8) = .empty;
- defer bytes.deinit(gpa);
- try frame(gpa, &bytes, 'h', &.{magic ++ " 1"});
- var line: [64]u8 = undefined;
- for (0..200) |i| try frame(gpa, &bytes, 'r', &.{std.fmt.bufPrint(&line, "1 1 0 0 /w/file{d}.zig", .{i}) catch unreachable});
- const out = try std.Io.Dir.cwd().createFile(testing.io, path, .{});
- defer out.close(testing.io);
- try out.writePositionalAll(testing.io, bytes.items, 0);
- var off: u64 = bytes.items.len;
- const big = try gpa.alloc(u8, 1 << 20);
- defer gpa.free(big);
- @memset(big, 'z');
- for (0..90) |i| {
- bytes.clearRetainingCapacity();
- var meta: [128]u8 = undefined;
- const m = std.fmt.bufPrint(&meta, "{x:0>16} {d} {d} 1 0 0 0 10\t/w/closed{d}\n", .{ @as(u64, 0xfeed), std.c.getpid(), i + 1, i }) catch unreachable;
- try frame(gpa, &bytes, 'c', &.{ m, big });
- try out.writePositionalAll(testing.io, bytes.items, off);
- off += bytes.items.len;
- }
- }
- const t0 = nowNs();
- const p = try testWindow(path);
- defer p.deinit();
- const load_ns = nowNs() - t0;
- var t = nowNs();
- for (0..1000) |_| p.store.refresh(p);
- const refresh_ns = (nowNs() - t) / 1000;
- t = nowNs();
- var name: [32]u8 = undefined;
- for (0..100) |i| {
- const f = std.fmt.bufPrint(&name, "/w/new{d}.zig", .{i}) catch unreachable;
- p.recent.opened(p.recentGpa(), f);
- p.recent.closed(p.recentGpa(), f, 1, 1, 0, 0);
- p.saveRecent();
- }
- const flush_ns = (nowNs() - t) / 100;
- const before = fileSize(path);
- p.store.garbage = true;
- p.recent.opened(p.recentGpa(), "/w/last.zig");
- t = nowNs();
- p.saveRecent();
- const compact_ns = nowNs() - t;
- std.debug.print("store timings: load {d} us, refresh (unchanged) {d} ns, flush one record {d} us, compaction {d} -> {d} bytes {d} ms\n", .{
- load_ns / 1000, refresh_ns, flush_ns / 1000, before, fileSize(path), compact_ns / 1_000_000,
- });
-}
-
-fn nowNs() u64 {
- return @intCast(clockNs());
-}