https://github.com/cablehead/per-sec
https://github.com/cablehead/per-sec
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cablehead/per-sec
- Owner: cablehead
- License: mit
- Created: 2024-12-13T16:32:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-13T16:43:05.000Z (over 1 year ago)
- Last Synced: 2025-09-29T16:52:04.697Z (9 months ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# per-sec
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.
## Installation
```bash
# Clone and install from GitHub
git clone https://github.com/cablehead/per-sec.git
cd per-sec
cargo install --path .
```
## Usage
```
per-sec [args...]
```
The program reads from stdin continuously, buffers the input, and every second:
1. Spawns the specified command with any provided arguments
2. Writes the buffered input to the command's stdin
3. 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.
## Examples
Count Bluesky firehose events per second:
```bash
websocat "wss://jetstream1.us-east.bsky.network/subscribe" | per-sec wc -l
```
Process batches of data every second:
```bash
cat stream.jsonl | per-sec jq -c 'group_by(.type)'
```
Monitor HTTP requests per second:
```bash
tail -f access.log | per-sec grep 'GET' | per-sec wc -l
```
## Dependencies
- Built with Rust
- Uses [timeout-readwrite](https://github.com/jcreekmore/timeout-readwrite-rs) for IO timeouts without an async runtime
## License
MIT