change allocator to raw_c_allocator

This commit is contained in:
Motiejus Jakštys 2022-07-04 23:15:16 +03:00
parent 1546871e2d
commit 84eb2ca6f0
2 changed files with 7 additions and 10 deletions

View File

@ -384,7 +384,7 @@ Profiling
Prepare `profile.data`: Prepare `profile.data`:
``` ```
zig build -Drelease-small=true zig build -Drelease-small=true && \
perf record --call-graph=dwarf \ perf record --call-graph=dwarf \
zig-out/bin/turbo-unix2db --passwd passwd2 --group group2 zig-out/bin/turbo-unix2db --passwd passwd2 --group group2
``` ```
@ -398,8 +398,7 @@ perf report -i perf.data
Flame graph: Flame graph:
``` ```
perf script | inferno-collapse-perf > stacks.folded perf script | inferno-collapse-perf | inferno-flamegraph > profile.svg
inferno-flamegraph stacks.folded > profile.svg
``` ```
[git-subtrac]: https://apenwarr.ca/log/20191109 [git-subtrac]: https://apenwarr.ca/log/20191109

View File

@ -3,9 +3,9 @@ const fs = std.fs;
const io = std.io; const io = std.io;
const mem = std.mem; const mem = std.mem;
const os = std.os; const os = std.os;
const heap = std.heap;
const ArrayList = std.ArrayList; const ArrayList = std.ArrayList;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator;
const flags = @import("flags.zig"); const flags = @import("flags.zig");
const User = @import("User.zig"); const User = @import("User.zig");
@ -26,14 +26,12 @@ const usage =
pub fn main() !void { pub fn main() !void {
// This line is here because of https://github.com/ziglang/zig/issues/7807 // This line is here because of https://github.com/ziglang/zig/issues/7807
const argv: []const [*:0]const u8 = os.argv; const argv: []const [*:0]const u8 = os.argv;
var gpa = GeneralPurposeAllocator(.{}){}; const gpa = heap.raw_c_allocator;
defer gpa.deinit();
const allocator = gpa.allocator();
const stderr = io.getStdErr().writer(); const stderr = io.getStdErr().writer();
const stdout = io.getStdOut().writer(); const stdout = io.getStdOut().writer();
const return_code = execute(allocator, stdout, stderr, argv[1..]); const return_code = execute(gpa, stdout, stderr, argv[1..]);
os.exit(return_code); os.exit(return_code);
} }