From e5b21467c891fe9a2956358a38b496a5d9a174fc Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 21 Nov 2023 10:38:15 -0800 Subject: [PATCH] add a lot more info to README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 100c0926dcd0686d0742a1a4e31cfbf6efb2eec3..7b2dcff608320cd4768b92be436dc19ceb4dbfdf 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ const std = @import("std"); const tracer = @import("tracer"); pub const build_options = @import("build_options"); -pub const tracer_impl = tracer.spall; // supports none, log, spall out of the box +pub const tracer_impl = tracer.spall; // see 'Backends' section below pub fn main() !void { try tracer.init(); @@ -43,6 +43,23 @@ fn handler() void { exe_options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); ``` +## Backends + +- `none` this is the default and causes tracing calls to become a no-op so that `tracer` can be added to libraries transparently +- `log` uses `std.log` to print on function entrance. +- `chrome` writes a json file in the `chrome://tracing` format described [here](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview) and [here](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/). +- `spall` writes a binary file compatible with the [Spall](https://gravitymoth.com/spall/) profiler. +- more? feel free to open an issue with requests! + +Any custom backend may also be used that defines the following functions: + +- `pub fn init() !void` +- `pub fn deinit() void` +- `pub fn init_thread() !void` +- `pub fn deinit_thread() void` +- `pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void` +- `pub inline fn trace_end(ctx: tracer.Ctx) void` + ## License MIT -- 2.54.0