Skip to documentation
SLOP

tiny.profiling.driver.paths

Reference tiny.profiling driver paths

Defined in driver.

API (5)

Actions

Public operations.

No direct callersNo direct callsdriverpaths
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsdriver.measurerunMeasuredWorkloadtest; no linksrc.profiling.driver.pathstest: profiling driver resolves artif...driver.pathsabsoluteExecutionArtifactEnvdriver.pathsabsoluteArtifactEnv
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsdriver.measurerunMeasuredWorkloaddriver.pathsabsoluteArtifactEnvprivate; no linksrc.profiling.driver.schedulerunInterleavedEntrydriver.pathsabsolutePathdriver.pathsabsoluteExecutionArtifactEnv
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsdriver.pathsabsoluteExecutionArtifactEnvdriver.pathsabsoluteWarmupArtifactEnvdriver.pathsabsolutePath
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsdriver.preparerunWarmupsdriver.pathsabsolutePathdriver.pathsabsoluteWarmupArtifactEnv
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsdriver.artifactcollectCapturestest; no linksrc.profiling.driver.pathstest: profiling driver rebases lane c...private; no linksrc.profiling.driver.pathsrebasePathdriver.pathsrebaseCaptures
Static calls · unresolved targets: 0 · external targets: 1.

Source: src/profiling/driver/paths.zig

zig
const std = @import("std");const sys = @import("sys");const execute = @import("../root.zig").execute;const host = @import("../root.zig").host;const record = @import("../root.zig").record;pub fn absoluteArtifactEnv(    allocator: std.mem.Allocator,    paths: record.WorkloadPaths,) !execute.ArtifactEnv {    std.debug.assert(paths.root.len > 0);    std.debug.assert(paths.allocations.len > paths.root.len);    return try absoluteExecutionArtifactEnv(allocator, .{        .root = paths.root,        .stdout = paths.stdout,        .stderr = paths.stderr,        .bench_jsonl = paths.bench_jsonl,        .coz_jsonl = paths.coz_jsonl,        .coz_analysis = paths.coz_analysis,        .tracy_jsonl = paths.tracy_jsonl,        .tracy_summary = paths.tracy_summary,        .allocations = paths.allocations,        .structured = paths.structured,    });}pub fn absoluteExecutionArtifactEnv(    allocator: std.mem.Allocator,    paths: record.ExecutionPaths,) !execute.ArtifactEnv {    std.debug.assert(paths.root.len > 0);    std.debug.assert(paths.allocations.len > paths.root.len);    return .{        .stdout = paths.stdout,        .stderr = paths.stderr,        .bench_jsonl = try absolutePath(allocator, paths.bench_jsonl),        .coz_jsonl = try absolutePath(allocator, paths.coz_jsonl),        .coz_analysis = try absolutePath(allocator, paths.coz_analysis),        .tracy_jsonl = try absolutePath(allocator, paths.tracy_jsonl),        .tracy_summary = try absolutePath(allocator, paths.tracy_summary),        .allocations = try absolutePath(allocator, paths.allocations),    };}pub fn absoluteWarmupArtifactEnv(    allocator: std.mem.Allocator,    paths: record.WarmupPaths,) !execute.ArtifactEnv {    std.debug.assert(paths.root.len > 0);    return .{        .stdout = paths.stdout,        .stderr = paths.stderr,        .bench_jsonl = try absolutePath(allocator, paths.bench_jsonl),        .coz_jsonl = try absolutePath(allocator, paths.coz_jsonl),        .coz_analysis = try absolutePath(allocator, paths.coz_analysis),        .tracy_jsonl = try absolutePath(allocator, paths.tracy_jsonl),        .tracy_summary = try absolutePath(allocator, paths.tracy_summary),        .allocations = try absolutePath(allocator, paths.allocations),    };}pub fn absolutePath(allocator: std.mem.Allocator, path: []const u8) ![]const u8 {    std.debug.assert(path.len > 0);    if (std.fs.path.isAbsolute(path)) return path;    const cwd = try sys.fs.cwdAlloc(allocator);    const result = try std.fs.path.join(allocator, &.{ cwd, path });    std.debug.assert(std.fs.path.isAbsolute(result));    return result;}pub fn rebaseCaptures(    allocator: std.mem.Allocator,    captures: []const host.Capture,    absolute_root: []const u8,    artifact_root: []const u8,) ![]const host.Capture {    std.debug.assert(std.fs.path.isAbsolute(absolute_root));    std.debug.assert(artifact_root.len > 0);    const rows = try allocator.dupe(host.Capture, captures);    for (rows) |*row| {        row.capture_path = try rebasePath(            allocator,            row.capture_path,            absolute_root,            artifact_root,        );        row.summary_path = try rebasePath(            allocator,            row.summary_path,            absolute_root,            artifact_root,        );    }    return rows;}fn rebasePath(    allocator: std.mem.Allocator,    path: []const u8,    absolute_root: []const u8,    artifact_root: []const u8,) ![]const u8 {    std.debug.assert(std.fs.path.isAbsolute(absolute_root));    std.debug.assert(artifact_root.len > 0);    if (!std.mem.startsWith(u8, path, absolute_root)) return path;    if (path.len == absolute_root.len) return artifact_root;    if (path[absolute_root.len] != std.fs.path.sep) return path;    return try std.fs.path.join(        allocator,        &.{ artifact_root, path[absolute_root.len + 1 ..] },    );}test "profiling driver rebases lane capture paths onto the requested run root" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const rows = try rebaseCaptures(allocator, &.{.{        .kind = "dhat",        .tool = "valgrind",        .capture_path = "/repo/zig-out/profiling/run/workloads/w/dhat.capture.txt",        .summary_path = "/repo/zig-out/profiling/run/workloads/w/dhat.summary.json",        .state = "summary_written",    }}, "/repo/zig-out/profiling/run/workloads/w", "zig-out/profiling/run/workloads/w");    try std.testing.expectEqualStrings(        "zig-out/profiling/run/workloads/w/dhat.capture.txt",        rows[0].capture_path,    );    try std.testing.expectEqualStrings(        "zig-out/profiling/run/workloads/w/dhat.summary.json",        rows[0].summary_path,    );    const absolute_rows = try rebaseCaptures(allocator, &.{.{        .kind = "dhat",        .tool = "valgrind",        .capture_path = "/tmp/profiling/run/workloads/w/dhat.capture.txt",        .summary_path = "/tmp/profiling/run/workloads/w/dhat.summary.json",        .state = "summary_written",    }}, "/tmp/profiling/run/workloads/w", "/tmp/profiling/run/workloads/w");    try std.testing.expectEqualStrings(        "/tmp/profiling/run/workloads/w/dhat.capture.txt",        absolute_rows[0].capture_path,    );    try std.testing.expectEqualStrings(        "/tmp/profiling/run/workloads/w/dhat.summary.json",        absolute_rows[0].summary_path,    );    const untouched = try rebasePath(        allocator,        "/elsewhere/dhat.out",        "/repo/zig-out/profiling/run/workloads/w",        "zig-out/x",    );    try std.testing.expectEqualStrings("/elsewhere/dhat.out", untouched);    const boundary = try rebasePath(        allocator,        "/repo/zig-out/profiling/run/workloads/wide/f",        "/repo/zig-out/profiling/run/workloads/w",        "zig-out/x",    );    try std.testing.expectEqualStrings("/repo/zig-out/profiling/run/workloads/wide/f", boundary);}test "profiling driver resolves artifact env paths to absolute paths" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const paths = record.WorkloadPaths{        .root = "zig-out/profiling/run/workloads/w",        .command = "zig-out/profiling/run/workloads/w/command.json",        .result = "zig-out/profiling/run/workloads/w/result.json",        .stdout = "zig-out/profiling/run/workloads/w/stdout.txt",        .stderr = "zig-out/profiling/run/workloads/w/stderr.txt",        .setup_stdout = "zig-out/profiling/run/workloads/w/setup.stdout.txt",        .setup_stderr = "zig-out/profiling/run/workloads/w/setup.stderr.txt",        .prepare_stdout = "zig-out/profiling/run/workloads/w/prepare.stdout.txt",        .prepare_stderr = "zig-out/profiling/run/workloads/w/prepare.stderr.txt",        .bench_jsonl = "zig-out/profiling/run/workloads/w/bench.jsonl",        .coz_jsonl = "zig-out/profiling/run/workloads/w/bench.coz.jsonl",        .coz_analysis = "zig-out/profiling/run/workloads/w/bench.coz.analysis.json",        .tracy_jsonl = "zig-out/profiling/run/workloads/w/bench.tracy.jsonl",        .tracy_summary = "zig-out/profiling/run/workloads/w/bench.tracy.summary.jsonl",        .allocations = "zig-out/profiling/run/workloads/w/allocations.jsonl",        .allocations_summary = "zig-out/profiling/run/workloads/w/allocations.summary.jsonl",        .allocation_repetitions = "zig-out/profiling/run/workloads/w/allocations.repetitions.jsonl",        .structured = "zig-out/profiling/run/workloads/w/structured.jsonl",        .warmup = .{            .root = "zig-out/profiling/run/workloads/w/warmup",            .stdout = "zig-out/profiling/run/workloads/w/warmup/stdout.txt",            .stderr = "zig-out/profiling/run/workloads/w/warmup/stderr.txt",            .bench_jsonl = "zig-out/profiling/run/workloads/w/warmup/bench.jsonl",            .coz_jsonl = "zig-out/profiling/run/workloads/w/warmup/bench.coz.jsonl",            .coz_analysis = "zig-out/profiling/run/workloads/w/warmup/bench.coz.analysis.json",            .tracy_jsonl = "zig-out/profiling/run/workloads/w/warmup/bench.tracy.jsonl",            .tracy_summary = "zig-out/profiling/run/workloads/w/warmup/bench.tracy.summary.jsonl",            .allocations = "zig-out/profiling/run/workloads/w/warmup/allocations.jsonl",        },    };    const env = try absoluteArtifactEnv(allocator, paths);    try std.testing.expect(std.fs.path.isAbsolute(env.bench_jsonl));    try std.testing.expect(std.fs.path.isAbsolute(env.tracy_jsonl));    try std.testing.expect(std.fs.path.isAbsolute(env.allocations));}

Source: src/profiling/driver/root.zig:7

zig
pub const paths = @import("paths.zig");

Audit

Definitions6
Public names9
Members0
Version26.7.0
Revisiondaab053ee433