Created
June 14, 2017 10:05
-
-
Save markusl/ff83bf0034716ec64e4ba00a37abc9d4 to your computer and use it in GitHub Desktop.
'yes' implementation in Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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