Skip to content

Instantly share code, notes, and snippets.

@markusl
Created June 14, 2017 10:05
Show Gist options
  • Save markusl/ff83bf0034716ec64e4ba00a37abc9d4 to your computer and use it in GitHub Desktop.
Save markusl/ff83bf0034716ec64e4ba00a37abc9d4 to your computer and use it in GitHub Desktop.
'yes' implementation in Rust
use std::io::{stdout, Write};
// Compile: rustc -O -C lto yes.rs
// Use: ./yes | pv > /dev/null
// 97GiB 0:00:57 [3.72GiB/s] [ <=> ]
fn main() {
let buffer = "y\n".repeat(16384).into_bytes();
let stdout = stdout();
let mut stdout = stdout.lock();
loop {
stdout.write(&buffer).unwrap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment