Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/zig-gamedev/ztracy
- Owner: zig-gamedev
- License: mit
- Created: 2024-11-04T21:45:01.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-04T23:00:27.000Z (3 months ago)
- Last Synced: 2024-11-05T00:17:03.526Z (3 months ago)
- Topics: bindings, profiling, tracy, zig
- Language: C++
- Homepage:
- Size: 321 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```