From b229aff34aeef059823c1ab7dfd3a1f5c4445d9e Mon Sep 17 00:00:00 2001 From: Harry Eakins Date: Thu, 19 Apr 2018 23:42:52 -0700 Subject: [PATCH] Readability improvements and bug-fix to std/crypto/throughput_test.zig --- std/crypto/throughput_test.zig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/std/crypto/throughput_test.zig b/std/crypto/throughput_test.zig index 60610411b5..c76f19e120 100644 --- a/std/crypto/throughput_test.zig +++ b/std/crypto/throughput_test.zig @@ -7,16 +7,15 @@ // zig build-exe --release-fast --library c throughput_test.zig // ./throughput_test // ``` -const HashFunction = @import("md5.zig").Md5; -const BytesToHash = 1024 * Mb; const std = @import("std"); - const c = @cImport({ @cInclude("time.h"); }); +const HashFunction = @import("md5.zig").Md5; -const Mb = 1024 * 1024; +const MB = 1024 * 1024; +const BytesToHash = 1024 * MB; pub fn main() !void { var stdout_file = try std.io.getStdOut(); @@ -35,9 +34,9 @@ pub fn main() !void { } const end = c.clock(); - const elapsed_s = f64((end - start) * c.CLOCKS_PER_SEC) / 1000000; + const elapsed_s = f64(end - start) / f64(c.CLOCKS_PER_SEC); const throughput = u64(BytesToHash / elapsed_s); try stdout.print("{}: ", @typeName(HashFunction)); - try stdout.print("{} Mb/s\n", throughput); + try stdout.print("{} MB/s\n", throughput / (1 * MB)); }