From aff90c22520bbbadd56fbfd1378f161ee8a3cdb2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 15 Jul 2019 20:35:34 -0400 Subject: avoid shipping junk files I did a diff of the shipped file list with master branch and it looks good after this commit. --- std/zig/bench.zig | 36 ------------------------------------ std/zig/perf_test.zig | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 std/zig/bench.zig create mode 100644 std/zig/perf_test.zig (limited to 'std') diff --git a/std/zig/bench.zig b/std/zig/bench.zig deleted file mode 100644 index e0723d8519..0000000000 --- a/std/zig/bench.zig +++ /dev/null @@ -1,36 +0,0 @@ -const std = @import("std"); -const mem = std.mem; -const warn = std.debug.warn; -const Tokenizer = std.zig.Tokenizer; -const Parser = std.zig.Parser; -const io = std.io; - -const source = @embedFile("../os.zig"); -var fixed_buffer_mem: [10 * 1024 * 1024]u8 = undefined; - -pub fn main() !void { - var i: usize = 0; - var timer = try std.time.Timer.start(); - const start = timer.lap(); - const iterations = 100; - var memory_used: usize = 0; - while (i < iterations) : (i += 1) { - memory_used += testOnce(); - } - const end = timer.read(); - memory_used /= iterations; - const elapsed_s = @intToFloat(f64, end - start) / std.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 = &stdout_file.outStream().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; - _ = std.zig.parse(allocator, source) catch @panic("parse failure"); - return fixed_buf_alloc.end_index; -} diff --git a/std/zig/perf_test.zig b/std/zig/perf_test.zig new file mode 100644 index 0000000000..e0723d8519 --- /dev/null +++ b/std/zig/perf_test.zig @@ -0,0 +1,36 @@ +const std = @import("std"); +const mem = std.mem; +const warn = std.debug.warn; +const Tokenizer = std.zig.Tokenizer; +const Parser = std.zig.Parser; +const io = std.io; + +const source = @embedFile("../os.zig"); +var fixed_buffer_mem: [10 * 1024 * 1024]u8 = undefined; + +pub fn main() !void { + var i: usize = 0; + var timer = try std.time.Timer.start(); + const start = timer.lap(); + const iterations = 100; + var memory_used: usize = 0; + while (i < iterations) : (i += 1) { + memory_used += testOnce(); + } + const end = timer.read(); + memory_used /= iterations; + const elapsed_s = @intToFloat(f64, end - start) / std.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 = &stdout_file.outStream().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; + _ = std.zig.parse(allocator, source) catch @panic("parse failure"); + return fixed_buf_alloc.end_index; +} -- cgit v1.2.3