Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler/ › Maker/ › WebServer.zig › updateTimeReportRunTest
updateTimeReportRunTest
WebServer.updateTimeReportRunTest
pub fn updateTimeReportRunTest (
ws : *WebServer ,
run_step_index : Configuration .Step .Index ,
tests : *const Step .Run .CachedTestMetadata ,
ns_per_test : []const u64 ,
) void
File
Code
pub fn updateTimeReportRunTest (
ws : *WebServer ,
run_step_index : Configuration .Step .Index ,
tests : *const Step .Run .CachedTestMetadata ,
ns_per_test : []const u64 ,
) void {
const graph = ws .graph ;
const io = graph .io ;
const configured = &ws .configured .?;
const maker = configured .maker ;
const gpa = maker .gpa ;
const all_steps = maker .step_stack .keys ();
const step_idx : u32 = for (all_steps , 0 ..) |s , i | {
if (s == run_step_index ) break @intCast (i );
} else unreachable ;
assert (tests .names .len == ns_per_test .len );
const tests_len : u32 = @intCast (tests .names .len );
const new_len : usize = len : {
var names_len : usize = 0 ;
for (0 ..tests_len ) |i | {
names_len += tests .testName (@intCast (i )).len + 1 ;
}
break :len @sizeOf (abi .time_report .RunTestResult ) + names_len + 8 * tests_len ;
};
const old_buf = old : {
configured .time_report_mutex .lock (io ) catch return ;
defer configured .time_report_mutex .unlock (io );
const old = configured .time_report_msgs [step_idx ];
configured .time_report_msgs [step_idx ] = &.{};
break :old old ;
};
const buf = gpa .realloc (old_buf , new_len ) catch @panic ("out of memory" );
const out_header : *align (1 ) abi .time_report .RunTestResult = @ptrCast (buf [0 ..@sizeOf (abi .time_report .RunTestResult )]);
out_header .* = .{
.step_idx = step_idx ,
.tests_len = tests_len ,
};
var offset : usize = @sizeOf (abi .time_report .RunTestResult );
const ns_per_test_out : []align (1 ) u64 = @ptrCast (buf [offset ..][0 .. tests_len * 8 ]);
@memcpy (ns_per_test_out , ns_per_test );
offset += tests_len * 8 ;
for (0 ..tests_len ) |i | {
const name = tests .testName (@intCast (i ));
@memcpy (buf [offset ..][0 ..name .len ], name );
buf [offset ..][name .len ] = 0 ;
offset += name .len + 1 ;
}
assert (offset == buf .len );
{
configured .time_report_mutex .lock (io ) catch return ;
defer configured .time_report_mutex .unlock (io );
assert (configured .time_report_msgs [step_idx ].len == 0 );
configured .time_report_msgs [step_idx ] = buf ;
configured .time_report_update_times [step_idx ] = ws .now ();
}
ws .notifyUpdate ();
}