Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zig-gamedev/ztracy

Performance markers for Tracy Frame Profiler in Zig.
https://github.com/zig-gamedev/ztracy

bindings profiling tracy zig

Last synced: 3 months ago
JSON representation

Performance markers for Tracy Frame Profiler in Zig.

Awesome Lists containing this project

README

        

# [ztracy](https://github.com/zig-gamedev/ztracy)

Performance markers for [Tracy 0.11.1](https://github.com/wolfpld/tracy) in Zig

Initial Zig bindings created by [Martin Wickham](https://github.com/SpexGuy/Zig-Tracy)

## Getting started

Example `build.zig`:

```zig
pub fn build(b: *std.Build) void {
const options = .{
.enable_ztracy = b.option(
bool,
"enable_ztracy",
"Enable Tracy profile markers",
) orelse false,
.enable_fibers = b.option(
bool,
"enable_fibers",
"Enable Tracy fiber support",
) orelse false,
.on_demand = b.option(
bool,
"on_demand",
"Build tracy with TRACY_ON_DEMAND",
) orelse false,
};

const exe = b.addExecutable(.{ ... });

const ztracy = b.dependency("ztracy", .{
.enable_ztracy = options.enable_ztracy,
.enable_fibers = options.enable_fibers,
.on_demand = options.on_demand,
});
exe.root_module.addImport("ztracy", ztracy.module("root"));
exe.linkLibrary(ztracy.artifact("tracy"));
}
```

Now in your code you may import and use `ztracy`. To build your project with Tracy enabled run:

`zig build -Denable_ztracy=true`

```zig
const ztracy = @import("ztracy");

pub fn main() !void {
{
const tracy_zone = ztracy.ZoneNC(@src(), "Compute Magic", 0x00_ff_00_00);
defer tracy_zone.End();
...
}
}
```

## Async "Fibers" support

Tracy has support for marking fibers (also called green threads,
coroutines, and other forms of cooperative multitasking). This support requires
an additional option passed through when compiling the Tracy library, so:

```zig
...
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

const ztracy_pkg = ztracy.package(b, target, optimize, .{
.options = .{ .enable_ztracy = true, .enable_fibers = true },
});

ztracy_pkg.link(exe);
```