MCPcopy Index your code
hub / github.com/codehamr/codehamr / humanRate

Function humanRate

internal/tui/format.go:48–57  ·  view source on GitHub ↗

humanRate renders throughput: `25 tok/s`, `5.3 tok/s`. Returns "" on degenerate input (no tokens or zero elapsed) so the caller omits the segment. Sub-10 tok/s keeps one decimal: reasoning models sit at 1.x where that decimal is the only signal; above 10 it's noise.

(tokens int, d time.Duration)

Source from the content-addressed store, hash-verified

46// segment. Sub-10 tok/s keeps one decimal: reasoning models sit at 1.x
47// where that decimal is the only signal; above 10 it's noise.
48func humanRate(tokens int, d time.Duration) string {
49 if tokens <= 0 || d <= 0 {
50 return ""
51 }
52 r := float64(tokens) / d.Seconds()
53 if r >= 10 {
54 return fmt.Sprintf("%d tok/s", int(r+0.5))
55 }
56 return fmt.Sprintf("%.1f tok/s", r)
57}
58
59// backendLabel renders the connection signal. Connected: profile name, bold,
60// no colour. Disconnected: bold yellow plus a `!` marker, so the state stays

Callers 3

finalizeTurnMethod · 0.85
TestHumanRateFormatFunction · 0.85
renderStatusBarMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestHumanRateFormatFunction · 0.68