| ... | @@ -19,20 +19,18 @@ pub fn main() !void { | ... | @@ -19,20 +19,18 @@ pub fn main() !void { |
| 19 | } | 19 | } |
| 20 | const end = timer.read(); | 20 | const end = timer.read(); |
| 21 | memory_used /= iterations; | 21 | memory_used /= iterations; |
| 22 | const elapsed_s = f64(end - start) / std.os.time.ns_per_s; | 22 | const elapsed_s = @intToFloat(f64, end - start) / std.os.time.ns_per_s; |
| 23 | const bytes_per_sec = f64(source.len * iterations) / elapsed_s; | 23 | const bytes_per_sec = @intToFloat(f64, source.len * iterations) / elapsed_s; |
| 24 | const mb_per_sec = bytes_per_sec / (1024 * 1024); | 24 | const mb_per_sec = bytes_per_sec / (1024 * 1024); |
| 25 | | 25 | |
| 26 | var stdout_file = try std.io.getStdOut(); | 26 | var stdout_file = try std.io.getStdOut(); |
| 27 | const stdout = *std.io.FileOutStream.init(*stdout_file).stream; | 27 | const stdout = &std.io.FileOutStream.init(&stdout_file).stream; |
| 28 | try stdout.print("{.3} MB/s, {} KB used \n", mb_per_sec, memory_used / 1024); | 28 | try stdout.print("{.3} MiB/s, {} KiB used \n", mb_per_sec, memory_used / 1024); |
| 29 | } | 29 | } |
| 30 | | 30 | |
| 31 | fn testOnce() usize { | 31 | fn testOnce() usize { |
| 32 | var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); | 32 | var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); |
| 33 | var allocator = *fixed_buf_alloc.allocator; | 33 | var allocator = &fixed_buf_alloc.allocator; |
| 34 | var tokenizer = Tokenizer.init(source); | 34 | _ = std.zig.parse(allocator, source) catch @panic("parse failure"); |
| 35 | var parser = Parser.init(*tokenizer, allocator, "(memory buffer)"); | | |
| 36 | _ = parser.parse() catch @panic("parse failure"); | | |
| 37 | return fixed_buf_alloc.end_index; | 35 | return fixed_buf_alloc.end_index; |
| 38 | } | 36 | } |