diff --git a/lib/build-web/fuzz.zig b/lib/build-web/fuzz.zig index 5fe0de2f7a..21eb3f868a 100644 --- a/lib/build-web/fuzz.zig +++ b/lib/build-web/fuzz.zig @@ -1,5 +1,6 @@ // Server timestamp. var start_fuzzing_timestamp: i64 = undefined; +var start_fuzzing_n_runs: u64 = undefined; const js = struct { extern "fuzz" fn requestSources() void; @@ -36,6 +37,7 @@ pub fn sourceIndexMessage(msg_bytes: []u8) error{OutOfMemory}!void { const source_locations: []const Coverage.SourceLocation = @alignCast(std.mem.bytesAsSlice(Coverage.SourceLocation, msg_bytes[source_locations_start..source_locations_end])); start_fuzzing_timestamp = header.start_timestamp; + start_fuzzing_n_runs = header.start_n_runs; try updateCoverageSources(directories, files, source_locations, string_bytes); js.ready(); } @@ -271,7 +273,7 @@ fn updateStats() error{OutOfMemory}!void { const avg_speed: f64 = speed: { const ns_elapsed: f64 = @floatFromInt(nsSince(start_fuzzing_timestamp)); - const n_runs: f64 = @floatFromInt(hdr.n_runs); + const n_runs: f64 = @floatFromInt(hdr.n_runs -% start_fuzzing_n_runs); break :speed n_runs / (ns_elapsed / std.time.ns_per_s); }; diff --git a/lib/std/Build/Fuzz.zig b/lib/std/Build/Fuzz.zig index 44bcf97a7a..b2477f5088 100644 --- a/lib/std/Build/Fuzz.zig +++ b/lib/std/Build/Fuzz.zig @@ -64,6 +64,7 @@ const CoverageMap = struct { /// Elements are indexes into `source_locations` pointing to the unit tests that are being fuzz tested. entry_points: std.ArrayList(u32), start_timestamp: i64, + start_n_runs: u64, fn deinit(cm: *CoverageMap, gpa: Allocator) void { std.posix.munmap(cm.mapped_memory); @@ -299,6 +300,7 @@ pub fn sendUpdate( .source_locations_len = @intCast(coverage_map.source_locations.len), .string_bytes_len = @intCast(coverage_map.coverage.string_bytes.items.len), .start_timestamp = coverage_map.start_timestamp, + .start_n_runs = coverage_map.start_n_runs, }; var iovecs: [5][]const u8 = .{ @ptrCast(&header), @@ -390,6 +392,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO .source_locations = undefined, // populated below .entry_points = .{}, .start_timestamp = ws.now(), + .start_n_runs = undefined, // populated below }; errdefer gop.value_ptr.coverage.deinit(gpa); @@ -467,6 +470,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO for (sorted_pcs.items(.index), sorted_pcs.items(.sl)) |i, sl| source_locations[i] = sl; gop.value_ptr.source_locations = source_locations; + gop.value_ptr.start_n_runs = header.n_runs; ws.notifyUpdate(); } diff --git a/lib/std/Build/abi.zig b/lib/std/Build/abi.zig index b7c1e7379d..68060ae16b 100644 --- a/lib/std/Build/abi.zig +++ b/lib/std/Build/abi.zig @@ -219,6 +219,7 @@ pub const fuzz = struct { string_bytes_len: u32, /// When, according to the server, fuzzing started. start_timestamp: i64 align(4), + start_n_runs: u64 align(4), }; /// WebSocket server->client.