diff --git a/benchmarks/zig/README.md b/benchmarks/zig/README.md index a8faa04..3d52b9c 100644 --- a/benchmarks/zig/README.md +++ b/benchmarks/zig/README.md @@ -1,6 +1,6 @@ # Zig implementations ``` -zig build run -Drelease-fast // -Dc if on posix systems +zig build run -Drelease-fast // add -Dc flag if on posix systems ``` Runs the quick sort benchmark using the thread pool in this repo which is written in [Ziglang](https://ziglang.org/). `async.zig` wraps the thread pool api which similar `async/await` syntax as the other languages in the benchmark. Also, I wrote two thread pools for curiousity. You can switch which one is used by changing the path to the zig file in `build.zig`. \ No newline at end of file diff --git a/benchmarks/zig/async.zig b/benchmarks/zig/async.zig index 9b6bd5e..7aeee5e 100644 --- a/benchmarks/zig/async.zig +++ b/benchmarks/zig/async.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const ThreadPool = @import("thread_pool"); /// Global thread pool which mimics other async runtimes @@ -53,13 +54,13 @@ pub fn run(comptime asyncFn: anytype, args: anytype) ReturnTypeOf(asyncFn) { // On windows, use the process heap allocator. // On posix systems, use the libc allocator. - const is_windows = std.builtin.target.os.tag == .windows; + const is_windows = builtin.target.os.tag == .windows; var win_heap: if (is_windows) std.heap.HeapAllocator else void = undefined; if (is_windows) { win_heap = @TypeOf(win_heap).init(); win_heap.heap_handle = std.os.windows.kernel32.GetProcessHeap() orelse unreachable; allocator = &win_heap.allocator; - } else if (std.builtin.link_libc) { + } else if (builtin.link_libc) { allocator = std.heap.c_allocator; } else { @compileError("link to libc with '-Dc' as zig stdlib doesn't provide a fast, libc-less, general purpose allocator (yet)");