aboutsummaryrefslogtreecommitdiff
path: root/lib/std/hash/benchmark.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-06-22 18:46:56 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-06-24 16:56:39 -0700
commitf26dda21171e26f44aeec8c59a75bbb3331eeb2e (patch)
treec935248861ae2693b314f2c8bc78fe38d9961b6d /lib/std/hash/benchmark.zig
parent447ca4e3fff021f471b748187b53f0a4744ad0bc (diff)
downloadzig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.tar.gz
zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.zip
all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
Diffstat (limited to 'lib/std/hash/benchmark.zig')
-rw-r--r--lib/std/hash/benchmark.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig
index 62df89f0ae..699de5ceb4 100644
--- a/lib/std/hash/benchmark.zig
+++ b/lib/std/hash/benchmark.zig
@@ -122,13 +122,13 @@ pub fn benchmarkHash(comptime H: anytype, bytes: usize, allocator: std.mem.Alloc
for (0..blocks_count) |i| {
h.update(blocks[i * alignment ..][0..block_size]);
}
- const final = if (H.has_crypto_api) @truncate(u64, h.finalInt()) else h.final();
+ const final = if (H.has_crypto_api) @as(u64, @truncate(h.finalInt())) else h.final();
std.mem.doNotOptimizeAway(final);
const end = timer.read();
- const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
- const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
+ const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
+ const throughput = @as(u64, @intFromFloat(@as(f64, @floatFromInt(bytes)) / elapsed_s));
return Result{
.hash = final,
@@ -152,7 +152,7 @@ pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize
const final = blk: {
if (H.init_u8s) |init| {
if (H.has_crypto_api) {
- break :blk @truncate(u64, H.ty.toInt(small_key, init[0..H.ty.key_length]));
+ break :blk @as(u64, @truncate(H.ty.toInt(small_key, init[0..H.ty.key_length])));
} else {
break :blk H.ty.hash(init, small_key);
}
@@ -166,8 +166,8 @@ pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize
}
const end = timer.read();
- const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
- const throughput = @intFromFloat(u64, @floatFromInt(f64, bytes) / elapsed_s);
+ const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
+ const throughput = @as(u64, @intFromFloat(@as(f64, @floatFromInt(bytes)) / elapsed_s));
std.mem.doNotOptimizeAway(sum);