zig

fork of https://codeberg.org/ziglang/zig
Log | Tree | Refs | README | LICENSE

commit 82e9190d0939a7f71df3d602e381b0ec7cccb561 (tree)
parent 410b4d9bdf8abb8dad2ac2e11038fe492b8be869
Author: Marc Tiehuis <marctiehuis@gmail.com>
Date:   Mon,  9 Jul 2018 17:14:04 +1200

Update zig.parser benchmark program

Diffstat:
Mstd/zig/bench.zig | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/std/zig/bench.zig b/std/zig/bench.zig @@ -19,20 +19,18 @@ pub fn main() !void { } const end = timer.read(); memory_used /= iterations; - const elapsed_s = f64(end - start) / std.os.time.ns_per_s; - const bytes_per_sec = f64(source.len * iterations) / elapsed_s; + const elapsed_s = @intToFloat(f64, end - start) / std.os.time.ns_per_s; + const bytes_per_sec = @intToFloat(f64, source.len * iterations) / elapsed_s; const mb_per_sec = bytes_per_sec / (1024 * 1024); var stdout_file = try std.io.getStdOut(); - const stdout = *std.io.FileOutStream.init(*stdout_file).stream; - try stdout.print("{.3} MB/s, {} KB used \n", mb_per_sec, memory_used / 1024); + const stdout = &std.io.FileOutStream.init(&stdout_file).stream; + try stdout.print("{.3} MiB/s, {} KiB used \n", mb_per_sec, memory_used / 1024); } fn testOnce() usize { var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); - var allocator = *fixed_buf_alloc.allocator; - var tokenizer = Tokenizer.init(source); - var parser = Parser.init(*tokenizer, allocator, "(memory buffer)"); - _ = parser.parse() catch @panic("parse failure"); + var allocator = &fixed_buf_alloc.allocator; + _ = std.zig.parse(allocator, source) catch @panic("parse failure"); return fixed_buf_alloc.end_index; }