Skip to documentation
SLOP

tiny.profiling.report.format

Reference tiny.profiling report format

Defined in report.

API (9)

Actions

Public operations.

Types and contracts

Public types and contracts.

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

Source

Called byCallstest; no linksrc.profiling.report.formattest: format memory and countsprivate; no linksrc.profiling.report.pagebytesCellprivate; no linksrc.profiling.report.pageformatMemoryprivate; no linksrc.profiling.report.pagememoryMetaprivate; no linksrc.profiling.report.pagememoryScopeSectionprivate; no linksrc.profiling.report.pagememoryWorkloadRowreport.formatkibreport.formatbytes
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linksrc.profiling.report.formattest: format memory and countsprivate; no linksrc.profiling.report.pageformatMemoryprivate; no linksrc.profiling.report.pagememoryScopeRowprivate; no linksrc.profiling.report.pagememoryScopeSectionprivate; no linksrc.profiling.report.pagerunAnalysisreport.formatcount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsreport.formatbytestest; no linksrc.profiling.report.formattest: format memory and countsprivate; no linksrc.profiling.report.pagerunWorkloadsreport.pageworkloadreport.formatkib
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsanalyze.renderwriteTextreport.formatsecondstest; no linksrc.profiling.report.formattest: format ns scales through unitsprivate; no linksrc.profiling.report.pagebenchmarkReductionRowprivate; no linksrc.profiling.report.pageexecutionWallCell+14 morereport.formatns
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linksrc.profiling.report.formattest: format percent carries signprivate; no linksrc.profiling.report.pagecausalCurveprivate; no linksrc.profiling.report.pageorderEffectsTableprivate; no linksrc.profiling.report.pagepercentCellprivate; no linksrc.profiling.report.pagerangePairCell+3 morereport.formatpercent
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linksrc.profiling.report.pagerunWorkloadsreport.pageworkloadreport.formatnsreport.formatseconds
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linksrc.profiling.report.formattest: format short shaprivate; no linksrc.profiling.report.pageindexRunsprivate; no linksrc.profiling.report.pagerunMetareport.formatshortSha
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linksrc.profiling.report.formattest: format timestamp renders utcprivate; no linksrc.profiling.report.pageindexLedeprivate; no linksrc.profiling.report.pageindexRunsprivate; no linksrc.profiling.report.pagerunMetaprivate; no linksrc.profiling.report.pageseriesChartreport.formattimestamp
Static calls · unresolved targets: 0 · external targets: 7.

Source: src/profiling/report/format.zig

zig
const std = @import("std");const Allocator = std.mem.Allocator;pub const Error = Allocator.Error;pub fn ns(allocator: Allocator, value: f64) Error![]u8 {    const magnitude = @abs(value);    if (magnitude < 1_000) return std.fmt.allocPrint(allocator, "{d:.0} ns", .{value});    if (magnitude < 1_000_000) return std.fmt.allocPrint(allocator, "{d:.1} µs", .{value / 1_000});    if (magnitude < 1_000_000_000) return std.fmt.allocPrint(allocator, "{d:.1} ms", .{value / 1_000_000});    if (magnitude < 60 * 1_000_000_000) return std.fmt.allocPrint(allocator, "{d:.2} s", .{value / 1_000_000_000});    const total_seconds = value / 1_000_000_000;    const minutes = @divTrunc(total_seconds, 60);    return std.fmt.allocPrint(allocator, "{d:.0} m {d:.0} s", .{ minutes, total_seconds - minutes * 60 });}pub fn kib(allocator: Allocator, value: f64) Error![]u8 {    const magnitude = @abs(value);    if (magnitude < 1024) return std.fmt.allocPrint(allocator, "{d:.0} KiB", .{value});    if (magnitude < 1024 * 1024) return std.fmt.allocPrint(allocator, "{d:.1} MiB", .{value / 1024});    return std.fmt.allocPrint(allocator, "{d:.2} GiB", .{value / (1024 * 1024)});}pub fn bytes(allocator: Allocator, value: f64) Error![]u8 {    const magnitude = @abs(value);    if (magnitude < 1024) return std.fmt.allocPrint(allocator, "{d:.0} B", .{value});    return kib(allocator, value / 1024);}pub fn count(allocator: Allocator, value: f64) Error![]u8 {    const magnitude = @abs(value);    if (magnitude < 10_000) return std.fmt.allocPrint(allocator, "{d:.0}", .{value});    if (magnitude < 1_000_000) return std.fmt.allocPrint(allocator, "{d:.1} k", .{value / 1_000});    if (magnitude < 1_000_000_000) return std.fmt.allocPrint(allocator, "{d:.1} M", .{value / 1_000_000});    return std.fmt.allocPrint(allocator, "{d:.1} G", .{value / 1_000_000_000});}pub fn percent(allocator: Allocator, value: f64) Error![]u8 {    if (value >= 0) return std.fmt.allocPrint(allocator, "+{d:.1}%", .{value});    return std.fmt.allocPrint(allocator, "{d:.1}%", .{value});}pub fn seconds(allocator: Allocator, value: f64) Error![]u8 {    return ns(allocator, value * 1_000_000_000);}pub fn timestamp(allocator: Allocator, unix_ns: i128) Error![]u8 {    if (unix_ns <= 0) return allocator.dupe(u8, "unknown");    const secs: u64 = @intCast(@divTrunc(unix_ns, std.time.ns_per_s));    const epoch_seconds = std.time.epoch.EpochSeconds{ .secs = secs };    const year_day = epoch_seconds.getEpochDay().calculateYearDay();    const month_day = year_day.calculateMonthDay();    const day_seconds = epoch_seconds.getDaySeconds();    return std.fmt.allocPrint(allocator, "{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2} UTC", .{        year_day.year,        month_day.month.numeric(),        month_day.day_index + 1,        day_seconds.getHoursIntoDay(),        day_seconds.getMinutesIntoHour(),    });}pub fn shortSha(sha: ?[]const u8) []const u8 {    const actual = sha orelse return "unknown";    return actual[0..@min(actual.len, 10)];}test "format ns scales through units" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    try std.testing.expectEqualStrings("512 ns", try ns(allocator, 512));    try std.testing.expectEqualStrings("1.5 µs", try ns(allocator, 1_500));    try std.testing.expectEqualStrings("32.0 ms", try ns(allocator, 32_028_329));    try std.testing.expectEqualStrings("2.05 s", try ns(allocator, 2_045_000_690));    try std.testing.expectEqualStrings("1 m 21 s", try ns(allocator, 80_837_892_135));}test "format memory and counts" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    try std.testing.expectEqualStrings("640 KiB", try kib(allocator, 640));    try std.testing.expectEqualStrings("1.7 MiB", try kib(allocator, 1_762));    try std.testing.expectEqualStrings("1.68 GiB", try kib(allocator, 1_762_464));    try std.testing.expectEqualStrings("96 B", try bytes(allocator, 96));    try std.testing.expectEqualStrings("64 KiB", try bytes(allocator, 65_536));    try std.testing.expectEqualStrings("387", try count(allocator, 387));    try std.testing.expectEqualStrings("12.5 k", try count(allocator, 12_500));}test "format percent carries sign" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    try std.testing.expectEqualStrings("+12.3%", try percent(allocator, 12.34));    try std.testing.expectEqualStrings("-4.2%", try percent(allocator, -4.2));}test "format timestamp renders utc" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    try std.testing.expectEqualStrings("2026-07-04 13:06 UTC", try timestamp(allocator, 1783170388327580663));    try std.testing.expectEqualStrings("unknown", try timestamp(allocator, 0));}test "format short sha" {    try std.testing.expectEqualStrings("abf0e4b279", shortSha("abf0e4b279ac79b61e1929655be71eee969e1aba"));    try std.testing.expectEqualStrings("unknown", shortSha(null));    try std.testing.expectEqualStrings("abc", shortSha("abc"));}

Source: src/profiling/report/root.zig:4

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

Complete caller list for report.format.ns

19 direct callers.

Complete caller list for report.format.percent

8 direct callers.

Audit

Definitions10
Public names10
Members0
Version26.7.0
Revisiondaab053ee433