Skip to content

SonnyTaylor/pi-tps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-tps-monitor

Pi extension that measures and displays average model TPS in the status bar.

Install

pi install npm:pi-tps-monitor

Or install from the local checkout:

pi install ./path/to/pi-tps

What it does

  • Tracks every assistant response in the current session.
  • Computes a running session-average TPS from the final usage.output token count and the wall-clock generation time.
  • Shows a live TPS estimate while the model is streaming (based on the number of stream deltas).
  • Resets the average when you change models so the number reflects the current model instead of blending fast and slow models together.
  • Displays the result in the Pi footer via ctx.ui.setStatus().

Try it

After installing, start Pi and send any prompt that produces a reasonably long reply, e.g.:

write a short poem about recursion

While streaming you'll see something like TPS 45.2 live; after the response finishes you'll see the session average, e.g. TPS 38.4 (last 42.1).

Commands

  • /tps – show current session TPS stats
  • /tps reset – reset the running average

How it works

Pi exposes extension events for the assistant message lifecycle:

  • message_start – start a timer when an assistant message begins.
  • message_update – count streaming deltas (text_delta, thinking_delta, toolcall_delta) for the live estimate.
  • message_end – read event.message.usage.output, compute elapsed time, and update the running average.
  • model_select – reset the running average when the active model changes.

Development

npm install
npm run typecheck

Package structure

.
├── package.json          # npm manifest + pi package manifest
├── tsconfig.json         # TypeScript config
├── src/
│   └── index.ts          # Extension entry point
├── test/
│   └── index.test.ts     # Unit tests
├── README.md
├── CHANGELOG.md
└── LICENSE

Caveats

  • The live estimate counts stream deltas, which is a proxy for tokens. The final average uses the provider's reported output token count, so it is accurate.
  • Stats are kept in memory for the current Pi process. They reset on restart. To persist across reloads/resumes, store them with pi.appendEntry() and rebuild the counters from ctx.sessionManager.getEntries() in session_start.

About

Pi extension that measures and displays model TPS in the status bar

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors