MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / format_token_count

Function format_token_count

src/display.rs:12–20  ·  view source on GitHub ↗

Formats a token count as a compact string (e.g. "1.2M", "45.3k").

(tokens: u64)

Source from the content-addressed store, hash-verified

10
11/// Formats a token count as a compact string (e.g. "1.2M", "45.3k").
12pub fn format_token_count(tokens: u64) -> String {
13 if tokens >= 1_000_000 {
14 format!("{:.1}M", tokens as f64 / 1_000_000.0)
15 } else if tokens >= 1_000 {
16 format!("{:.1}k", tokens as f64 / 1_000.0)
17 } else {
18 tokens.to_string()
19 }
20}
21
22/// Formats a UNIX timestamp as a human-readable relative time (e.g. "2m ago", "3d ago").
23/// Returns "never" when the timestamp is 0.

Callers 8

print_gain_totalFunction · 0.85
print_gain_historyFunction · 0.85
handle_listFunction · 0.85
monitor_loopFunction · 0.85
print_model_tableFunction · 0.85
print_default_summaryFunction · 0.85
print_cost_rowFunction · 0.85
hook_stopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected