Skip to content

Altagos/zig-spall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-spall

builds.sr.ht status

Zig library for generating spall-web profiling reports. Tested with Zig version 0.12.0-dev.2043+6ebeb85ab

Installation

First add it as dependencie to your build.zig.zon file:

.dependencies = .{
    .spall = .{
        .url = "https://git.sr.ht/~altagos/zig-spall/archive/{{COMMIT}}.tar.gz"
        .hash = "{{HASH}}"
    },
}

Replace {{COMMIT}} with the latest commit, and {{HASH}} will get generated during the next build (and displayed for you to copy and replace).

Then in build.zig add it to your Compile step like this:

const spall = b.dependency("spall", .{
    .target = target,
    .optimize = optimize,
    .enable = true, // Disabling spall will make any function call a nop (no operation), default: false
});

exe.addModule("spall", spall.module("spall"));

Usage

In your program:

const std = @import("std");
const spall = @import("spall");

pub fn main() !void {
    try spall.init("./trace/example.spall");
    defer spall.deinit();

    while (true) {
        try spall.init_thread();
        defer spall.deinit_thread();

        const span = spall.trace(@src(), "Hello World", .{});
        std.debug.print("Hello World!\n");
        span.end();
    }
}

An example with threads is in the example folder.

Similar libraries & other profiling libraries

TODO

  • add enable and disable options
  • add compatibility with zig-tracer
  • add documentation
  • add test (?)

License

MIT, see LICENSE

About

[mirror] Zig library for generating spall-web profiling reports.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages