tiny.tracy.report
Defined in tiny.tracy.
API (2)
Actions
Public operations.
Source
Source: lib/tracy/src/report.zig
zig
const std = @import("std");const sys = @import("sys");pub fn writeFromJsonlPath( comptime Analyzer: type, comptime write: anytype, allocator: std.mem.Allocator, path: []const u8, writer: *std.Io.Writer, options: anytype,) !void { var analyzer = Analyzer.init(allocator); defer analyzer.deinit(); try ingestJsonlPath(&analyzer, path); try write(allocator, &analyzer, writer, options);}pub fn ingestJsonlPath(analyzer: anytype, path: []const u8) !void { var file = try sys.fs.cwd().openFile(sys.fs.debugIo(), path, .{}); defer file.close(sys.fs.debugIo()); var buffer: [64 * 1024]u8 = undefined; var reader = file.reader(sys.fs.debugIo(), &buffer); while (true) { const line = reader.interface.takeDelimiter('\n') catch |err| switch (err) { error.ReadFailed => return reader.err.?, else => return err, }; const actual = line orelse break; try analyzer.ingestJsonLine(actual); }}test "report ingests JSONL path and writes through analyzer" { const allocator = std.testing.allocator; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); const root = try tmp.parent_dir.realPathFileAlloc(sys.fs.debugIo(), tmp.sub_path[0..], allocator); defer allocator.free(root); const path = try std.fs.path.join(allocator, &.{ root, "trace.jsonl" }); defer allocator.free(path); try sys.fs.cwd().writeFile(sys.fs.debugIo(), .{ .sub_path = path, .data = "one\ntwo\n" }); var out = std.Io.Writer.Allocating.init(allocator); defer out.deinit(); try writeFromJsonlPath(TestAnalyzer, writeTestAnalyzer, allocator, path, &out.writer, {}); try std.testing.expectEqualStrings("lines=2 first=one", out.written());}const TestAnalyzer = struct { allocator: std.mem.Allocator, lines: std.ArrayListUnmanaged([]u8) = .empty, pub fn init(allocator: std.mem.Allocator) TestAnalyzer { return .{ .allocator = allocator }; } pub fn deinit(self: *TestAnalyzer) void { for (self.lines.items) |line| self.allocator.free(line); self.lines.deinit(self.allocator); } pub fn ingestJsonLine(self: *TestAnalyzer, line: []const u8) !void { try self.lines.append(self.allocator, try self.allocator.dupe(u8, line)); }};fn writeTestAnalyzer( allocator: std.mem.Allocator, analyzer: *TestAnalyzer, writer: *std.Io.Writer, _: void,) !void { _ = allocator; try writer.print("lines={d} first={s}", .{ analyzer.lines.items.len, analyzer.lines.items[0] });}Source: lib/tracy/src/root.zig:57
zig
pub const report = @import("report.zig");Complete caller list for report.ingestJsonlPath
12 direct callers.
tiny.tracy.compare.ingestPath[function] atlib/tracy/src/compare.zig:718tiny.tracy.context.ingestPath[function] atlib/tracy/src/context.zig:785tiny.tracy.fibers.ingestPath[function] atlib/tracy/src/fiber.zig:566tiny.tracy.frame.ingestPath[function] atlib/tracy/src/frame.zig:268tiny.tracy.gpu.ingestPath[function] atlib/tracy/src/gpu.zig:1011tiny.tracy.locks.ingestPath[function] atlib/tracy/src/lock.zig:634tiny.tracy.memory.ingestPath[function] atlib/tracy/src/memory.zig:456tiny.tracy.plots.ingestPath[function] atlib/tracy/src/plot.zig:359tiny.tracy.report.writeFromJsonlPath[function] atlib/tracy/src/report.zig:4tiny.tracy.samples.ingestPath[function] atlib/tracy/src/sample.zig:498tiny.tracy.system.ingestPath[function] atlib/tracy/src/system.zig:449tiny.tracy.timeline.ingestPath[function] atlib/tracy/src/timeline.zig:443
Complete caller list for report.writeFromJsonlPath
21 direct callers.
tiny.tracy.context.writeJsonlFromJsonlPath[function] atlib/tracy/src/context.zig:776tiny.tracy.context.writeTextFromJsonlPath[function] atlib/tracy/src/context.zig:767tiny.tracy.fibers.writeJsonlFromJsonlPath[function] atlib/tracy/src/fiber.zig:557tiny.tracy.fibers.writeTextFromJsonlPath[function] atlib/tracy/src/fiber.zig:548tiny.tracy.frame.writeJsonlFromJsonlPath[function] atlib/tracy/src/frame.zig:259tiny.tracy.frame.writeTextFromJsonlPath[function] atlib/tracy/src/frame.zig:250tiny.tracy.gpu.writeJsonlFromJsonlPath[function] atlib/tracy/src/gpu.zig:1002tiny.tracy.gpu.writeTextFromJsonlPath[function] atlib/tracy/src/gpu.zig:993tiny.tracy.locks.writeJsonlFromJsonlPath[function] atlib/tracy/src/lock.zig:625tiny.tracy.locks.writeTextFromJsonlPath[function] atlib/tracy/src/lock.zig:616tiny.tracy.memory.writeJsonlFromJsonlPath[function] atlib/tracy/src/memory.zig:447tiny.tracy.memory.writeTextFromJsonlPath[function] atlib/tracy/src/memory.zig:438tiny.tracy.plots.writeJsonlFromJsonlPath[function] atlib/tracy/src/plot.zig:350tiny.tracy.plots.writeTextFromJsonlPath[function] atlib/tracy/src/plot.zig:341lib.tracy.src.report.test_report_ingests_JSONL_path_and_writes_through_analyzer[function] — test source atlib/tracy/src/report.zig:34in nearest public ownertiny.tracy.reporttiny.tracy.samples.writeJsonlFromJsonlPath[function] atlib/tracy/src/sample.zig:489tiny.tracy.samples.writeTextFromJsonlPath[function] atlib/tracy/src/sample.zig:480tiny.tracy.system.writeJsonlFromJsonlPath[function] atlib/tracy/src/system.zig:440tiny.tracy.system.writeTextFromJsonlPath[function] atlib/tracy/src/system.zig:431tiny.tracy.timeline.writeJsonlFromJsonlPath[function] atlib/tracy/src/timeline.zig:434tiny.tracy.timeline.writeTextFromJsonlPath[function] atlib/tracy/src/timeline.zig:425
Audit
| Definitions | 3 |
|---|---|
| Public names | 3 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |