A Unix-style tool that buffers stdin and executes a command with the buffered input every second, following the philosophy of djb's tool chain design.
# Clone and install from GitHub
git clone https://github.com/cablehead/per-sec.git
cd per-sec
cargo install --path .
per-sec <command> [args...]
The program reads from stdin continuously, buffers the input, and every second:
- Spawns the specified command with any provided arguments
- Writes the buffered input to the command's stdin
- Clears the buffer for the next second
If no input is received during a one-second window, the command is still executed with an empty stdin.
Count Bluesky firehose events per second:
websocat "wss://jetstream1.us-east.bsky.network/subscribe" | per-sec wc -l
Process batches of data every second:
cat stream.jsonl | per-sec jq -c 'group_by(.type)'
Monitor HTTP requests per second:
tail -f access.log | per-sec grep 'GET' | per-sec wc -l
- Built with Rust
- Uses timeout-readwrite for IO timeouts without an async runtime
MIT