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 @@...@@ -7,16 +7,15 @@
7// zig build-exe --release-fast --library c throughput_test.zig7// zig build-exe --release-fast --library c throughput_test.zig
8// ./throughput_test8// ./throughput_test
9// ```9// ```
10const HashFunction = @import("md5.zig").Md5;
11const BytesToHash = 1024 * Mb;
1210
13const std = @import("std");11const std = @import("std");
14
15const c = @cImport({12const c = @cImport({
16 @cInclude("time.h");13 @cInclude("time.h");
17});14});
15const HashFunction = @import("md5.zig").Md5;
1816
19const Mb = 1024 * 1024;17const MB = 1024 * 1024;
18const BytesToHash = 1024 * MB;
2019
21pub fn main() !void {20pub fn main() !void {
22 var stdout_file = try std.io.getStdOut();21 var stdout_file = try std.io.getStdOut();
...@@ -35,9 +34,9 @@ pub fn main() !void {...@@ -35,9 +34,9 @@ pub fn main() !void {
35 }34 }
36 const end = c.clock();35 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);
39 const throughput = u64(BytesToHash / elapsed_s);38 const throughput = u64(BytesToHash / elapsed_s);
4039
41 try stdout.print("{}: ", @typeName(HashFunction));40 try stdout.print("{}: ", @typeName(HashFunction));
42 try stdout.print("{} Mb/s\n", throughput);41 try stdout.print("{} MB/s\n", throughput / (1 * MB));
43}42}