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 › benchmarkMac
benchmarkMac
benchmark.benchmarkMac
pub fn benchmarkMac (comptime Mac : anytype , comptime bytes : comptime_int , io : Io ) !u64
File
Code
pub fn benchmarkMac (comptime Mac : anytype , comptime bytes : comptime_int , io : Io ) !u64 {
var in : [512 * KiB ]u8 = undefined ;
random .bytes (in [0 ..]);
const key_length = if (Mac .key_length == 0 ) 32 else Mac .key_length ;
var key : [key_length ]u8 = undefined ;
random .bytes (key [0 ..]);
var mac : [Mac .mac_length ]u8 = undefined ;
var offset : usize = 0 ;
const start = benchTime (io );
while (offset < bytes ) : (offset += in .len ) {
Mac .create (mac [0 ..], in [0 ..], key [0 ..]);
mem .doNotOptimizeAway (&mac );
}
const end = benchTime (io );
const elapsed_s = @as (f64 , @floatFromInt (end - start )) / time .ns_per_s ;
const throughput = @as (u64 , @intFromFloat (bytes / elapsed_s ));
return throughput ;
}