| ... | ... | @@ -16,7 +16,7 @@ const std = @import("std"); |
| 16 | 16 | const tracer = @import("tracer"); |
| 17 | 17 | pub const build_options = @import("build_options"); |
| 18 | 18 | |
| 19 | | pub const tracer_impl = tracer.spall; // supports none, log, spall out of the box |
| 19 | pub const tracer_impl = tracer.spall; // see 'Backends' section below |
| 20 | 20 | |
| 21 | 21 | pub fn main() !void { |
| 22 | 22 | try tracer.init(); |
| ... | ... | @@ -43,6 +43,23 @@ fn handler() void { |
| 43 | 43 | exe_options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); |
| 44 | 44 | ``` |
| 45 | 45 | |
| 46 | ## Backends |
| 47 | |
| 48 | - `none` this is the default and causes tracing calls to become a no-op so that `tracer` can be added to libraries transparently |
| 49 | - `log` uses `std.log` to print on function entrance. |
| 50 | - `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/). |
| 51 | - `spall` writes a binary file compatible with the [Spall](https://gravitymoth.com/spall/) profiler. |
| 52 | - more? feel free to open an issue with requests! |
| 53 | |
| 54 | Any custom backend may also be used that defines the following functions: |
| 55 | |
| 56 | - `pub fn init() !void` |
| 57 | - `pub fn deinit() void` |
| 58 | - `pub fn init_thread() !void` |
| 59 | - `pub fn deinit_thread() void` |
| 60 | - `pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void` |
| 61 | - `pub inline fn trace_end(ctx: tracer.Ctx) void` |
| 62 | |
| 46 | 63 | ## License |
| 47 | 64 | |
| 48 | 65 | MIT |