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 › std/ › crypto/ › benchmark.zig › benchmarkBatchSignatureVerification
benchmarkBatchSignatureVerification
benchmark.benchmarkBatchSignatureVerification
pub fn benchmarkBatchSignatureVerification (comptime Signature : anytype , comptime signatures_count : comptime_int , io : std .Io ) !u64
File
Code
pub fn benchmarkBatchSignatureVerification (comptime Signature : anytype , comptime signatures_count : comptime_int , io : std .Io ) !u64 {
const msg : [64 ]u8 = @splat (0 );
const key_pair = Signature .KeyPair .generate (io );
const sig = try key_pair .sign (&msg , null );
var batch : [64 ]Signature .BatchElement = undefined ;
for (&batch ) |*element | {
element .* = Signature .BatchElement { .sig = sig , .msg = &msg , .public_key = key_pair .public_key };
}
const start = benchTime (io );
{
var i : usize = 0 ;
while (i < signatures_count ) : (i += 1 ) {
try Signature .verifyBatch (io , batch .len , batch );
mem .doNotOptimizeAway (&sig );
}
}
const end = benchTime (io );
const elapsed_s = @as (f64 , @floatFromInt (end - start )) / time .ns_per_s ;
const throughput = batch .len * @as (u64 , @intFromFloat (signatures_count / elapsed_s ));
return throughput ;
}