authorgravatar for harry.eakins@googlemail.comHarry Eakins <harry.eakins@googlemail.com> 2018-04-19 23:42:52-07:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-04-21 11:06:10+12:00
logb229aff34aeef059823c1ab7dfd3a1f5c4445d9e
tree695ffb7469987149c16438de4f83551839ac5bb8
parent6e57243a79b08f37b80122f0eb24d073d6e2e95c

Readability improvements and bug-fix to std/crypto/throughput_test.zig


1 files changed, 5 insertions(+), 6 deletions(-)

std/crypto/throughput_test.zig+5-6
......@@ -7,16 +7,15 @@
77// zig build-exe --release-fast --library c throughput_test.zig
88// ./throughput_test
99// ```
10const HashFunction = @import("md5.zig").Md5;
11const BytesToHash = 1024 * Mb;
1210
1311const std = @import("std");
14
1512const c = @cImport({
1613 @cInclude("time.h");
1714});
15const HashFunction = @import("md5.zig").Md5;
1816
19const Mb = 1024 * 1024;
17const MB = 1024 * 1024;
18const BytesToHash = 1024 * MB;
2019
2120pub fn main() !void {
2221 var stdout_file = try std.io.getStdOut();
......@@ -35,9 +34,9 @@ pub fn main() !void {
3534 }
3635 const end = c.clock();
3736
38 const elapsed_s = f64((end - start) * c.CLOCKS_PER_SEC) / 1000000;
37 const elapsed_s = f64(end - start) / f64(c.CLOCKS_PER_SEC);
3938 const throughput = u64(BytesToHash / elapsed_s);
4039
4140 try stdout.print("{}: ", @typeName(HashFunction));
42 try stdout.print("{} Mb/s\n", throughput);
41 try stdout.print("{} MB/s\n", throughput / (1 * MB));
4342}