this repo has no description

groundwork for partial samples

altagos.dev 6a920a07 b2983bf5

verified
+24 -11
+24 -11
src/austin.zig
··· 1 1 const std = @import("std"); 2 2 const mem = std.mem; 3 3 4 - pub const Sample = struct { 4 + pub const Process = struct { 5 5 /// Process ID 6 6 pid: usize, 7 7 /// Sub-interpreter ID, 8 8 iid: usize, 9 9 /// Thread ID 10 10 tid: usize, 11 - frames: []FrameWrapper, 12 - metric: Metric, 13 - }; 14 - 15 - pub const SampleWrapper = union(enum) { 16 - full: Sample, 17 - metric: Metric, 18 11 }; 19 12 20 13 pub const Frame = struct { ··· 34 27 idle_state: bool, 35 28 /// positive for memory allocations, negative for deallocations 36 29 rss_memory_delta: isize, 30 + }; 31 + 32 + pub const Sample = struct { 33 + process: Process, 34 + frames: []FrameWrapper, 35 + metric: Metric, 36 + }; 37 + 38 + pub const PartialSample = struct { 39 + process: Process, 40 + frames: []FrameWrapper, 41 + }; 42 + 43 + pub const SampleWrapper = union(enum) { 44 + full: Sample, 45 + partial: PartialSample, 46 + metric: Metric, 37 47 }; 38 48 39 49 pub const Metadata = struct { ··· 201 211 202 212 // PID 203 213 const pid = data.next() orelse return ParseError.NoPID; 204 - sample.pid = std.fmt.parseUnsigned(usize, pid[1..], 0) catch return ParseError.InvalidPID; 205 214 206 215 const thread_raw = data.next() orelse return ParseError.NoThreadInfo; 207 216 var thread = std.mem.tokenizeScalar(u8, thread_raw, ':'); 208 217 209 218 // IID 210 219 const iid = thread.next() orelse return ParseError.NoIID; 211 - sample.iid = std.fmt.parseUnsigned(usize, iid[1..], 0) catch return ParseError.InvalidIID; 212 220 213 221 // TID 214 222 const tid = thread.next() orelse return ParseError.NoTID; 215 - sample.tid = std.fmt.parseUnsigned(usize, tid, 0) catch return ParseError.InvalidTID; 223 + 224 + sample.process = .{ 225 + .pid = std.fmt.parseUnsigned(usize, pid[1..], 0) catch return ParseError.InvalidPID, 226 + .iid = std.fmt.parseUnsigned(usize, iid[1..], 0) catch return ParseError.InvalidIID, 227 + .tid = std.fmt.parseUnsigned(usize, tid, 0) catch return ParseError.InvalidTID, 228 + }; 216 229 217 230 // Frames 218 231 var frames: std.ArrayList(FrameWrapper) = try .initCapacity(self.arena, 1);