summaryrefslogtreecommitdiff
path: root/test/lspbench.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/lspbench.zig')
-rw-r--r--test/lspbench.zig22
1 files changed, 12 insertions, 10 deletions
diff --git a/test/lspbench.zig b/test/lspbench.zig
index 307bdc49..9eddf2f0 100644
--- a/test/lspbench.zig
+++ b/test/lspbench.zig
@@ -81,7 +81,9 @@ const anchors = [_]Anchor{
.{ .file = "test/lspfixture/broken.zig", .needle = "unused_local", .at = 0, .kind = .diagnostics, .expect = "broken.zig" },
// the remaining kinds, probed once each so the matrix is complete
.{ .file = "src/lsp.zig", .needle = "lineCol(source", .at = 0, .kind = .declaration, .expect = "" },
- .{ .file = "src/lsp.zig", .needle = "out: *std.ArrayList(u8)", .at = 10, .kind = .type_definition, .expect = "" },
+ // cursor on `out`, whose type is `*std.Io.Writer` — a type_definition probe
+ // wants a NAME whose type must be resolved, not the type spelled out
+ .{ .file = "src/lsp.zig", .needle = "out: *std.Io.Writer", .at = 0, .kind = .type_definition, .expect = "" },
.{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .implementation, .expect = "" },
.{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .select_refs, .expect = "" },
.{ .file = "test/lspfixture/broken.zig", .needle = "badly_spaced", .at = 0, .kind = .format, .expect = "" },
@@ -156,12 +158,12 @@ pub fn main(init: std.process.Init) !void {
std.mem.sort(u64, &samples, {}, std.sort.asc(u64));
r.warm_us = samples[warm_iters / 2];
r.correct = !r.empty and (an.expect.len == 0 or blk: {
- var out: std.ArrayList(u8) = .empty;
- defer out.deinit(gpa);
+ var out: std.Io.Writer.Allocating = .init(gpa);
+ defer out.deinit();
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
- lsp.query(gpa, arena.allocator(), req, &out);
- break :blk std.mem.indexOf(u8, out.items, an.expect) != null;
+ lsp.query(gpa, arena.allocator(), req, &out.writer);
+ break :blk std.mem.indexOf(u8, out.written(), an.expect) != null;
});
try results.append(gpa, r);
}
@@ -173,14 +175,14 @@ pub fn main(init: std.process.Init) !void {
fn runOnce(gpa: std.mem.Allocator, req: lsp.Req, r: *Result) u64 {
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
- var out: std.ArrayList(u8) = .empty;
- defer out.deinit(gpa);
+ var out: std.Io.Writer.Allocating = .init(gpa);
+ defer out.deinit();
const t0 = nowNs();
- lsp.query(gpa, arena.allocator(), req, &out);
+ lsp.query(gpa, arena.allocator(), req, &out.writer);
const ns = nowNs() -| t0;
- if (out.items.len > 0) {
+ if (out.written().len > 0) {
r.empty = false;
- r.rows = std.mem.count(u8, out.items, "\n");
+ r.rows = std.mem.count(u8, out.written(), "\n");
}
return ns / 1000;
}