What triggers cost
Measured on 1 December 2026. A trigger matches each line of a program's output as it ends. This report measures what that costs the output that a terminal prints fastest, cat of a large file, of the same bundle of no trigger, of one and of ten. The session's report is in triggers-F5b-115, of the scenario triggers.
cat of 1 GiB
Each copy printed 1 GiB of plain text, lines of 79 characters of ASCII, five times in turned orders, on a MacBook Pro of an M5 Pro, the display at 60 Hz. The rate is from the file's first byte to the terminal's quiet.
| Triggers | Median | 95 % interval of the median | Against none |
|---|---|---|---|
| None | 307.0 MiB/s | 306.5 … 313.8 | |
| One | 306.4 MiB/s | 304.4 … 314.9 | −0.6 |
| Ten | 309.2 MiB/s | 305.4 … 310.9 | +2.2 (+0.7 %), −5.4 … +3.9: within the noise |
- The ten triggers are the patterns of a build's errors and warnings, a test's failures, a panic,
TODO, URLs, IP addresses, exceptions, a stack's frames and a ticket's number, each a highlight. None matches the text, as most of a program's lines match none. - Every budget holds: the releases' budget of
cat, 284.8 MiB/s, of ten triggers too.
Where the matching goes
The terminal's own work, of cargo bench, on the same Mac:
| Bench | Before | After |
|---|---|---|
| One trigger over 100 000 lines of 79 characters, read from the cells | 31.4 ms | 12.0 ms |
| Ten triggers, alike | 39.0 ms | 16.0 ms |
| The parse of 1 MiB of plain lines, of no trigger | 328 µs | 328 µs |
| The parse of 1 MiB of plain lines, its lines' text kept for the triggers | 475 µs |
- Reading a line from the screen's cells cost the most, not the patterns: one pattern that matches nowhere took as long as one of a build's errors. A first reading of each line's text, an ASCII character's cell of one step, and of the cells' columns only for a line that a trigger matches, took it from 31.4 ms to 12.0 ms, about 1.5 ms a MiB, which the output's thread would have paid.
- A line that streams at the screen's bottom is now matched of its text, which the terminal keeps as it prints it, a byte a cell, on a thread of its own: the output's thread copies the bytes, 0.15 ms a MiB of plain lines, and reads no cell. The other lines, which a program drew with the cursor moved, are read from their cells as before.
- Without triggers, the terminal keeps no line's text and starts no thread: one test of a flag a stretch of printed text and a line feed.