Skip to content

Add token speed widgets (InputSpeed, OutputSpeed, TotalSpeed)#141

Open
olion500 wants to merge 1 commit intosirmalloc:mainfrom
olion500:main
Open

Add token speed widgets (InputSpeed, OutputSpeed, TotalSpeed)#141
olion500 wants to merge 1 commit intosirmalloc:mainfrom
olion500:main

Conversation

@olion500
Copy link

Overview

This PR adds three new widgets that display token throughput (tokens per second) for Claude Code sessions:

  • InputSpeed: Shows input token processing rate
  • OutputSpeed: Shows output token generation rate
  • TotalSpeed: Shows combined token throughput

Motivation

Token speed metrics help users understand Claude's response performance and can be useful for:

  • Monitoring API performance during sessions
  • Identifying slow responses
  • Comparing throughput across different models

Implementation Details

Speed Calculation

Speed is calculated by measuring active processing time - the time between user requests and assistant responses:

activeTime = sum of (assistant response timestamp - user request timestamp) for each pair
speed = totalTokens / activeTime

This approach excludes idle time (user thinking, typing) and gives a more accurate representation of Claude's response throughput.

Note: The measured speed includes tool execution time (file reads, bash commands, etc.), so output speed may appear lower than pure token generation speed.

Configuration Example

{
  "lines": [
    {
      "items": [
        { "type": "InputSpeed", "color": "cyan" },
        { "type": "OutputSpeed", "color": "cyan" },
        { "type": "TotalSpeed", "color": "cyan" }
      ]
    }
  ]
}

Example Output

In: 10.9 t/s | Out: 1.3 t/s | Total: 12.2 t/s

- Add SpeedMetrics type for tracking token throughput
- Implement speed calculation utilities in speed-metrics.ts
- Add InputSpeed, OutputSpeed, TotalSpeed widgets
- Extend jsonl.ts to extract timing data for speed calculation
- Inject speedMetrics into RenderContext for widget access
- Add unit tests for speed widgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments