Println!() vs write!() + std::io::stdout().lock()
⚓ Rust 📅 2025-05-01 👤 surdeus 👁️ 10Context: figuring out the less-than-obvious parts of std.
Getting some mixed results from the use of println!(...) macro vs manual locking of the std::io::stdout() before calling the write!(...) on the lock() of the Stdout itself.
Sample code is here.
Question: how come the playground's execution is on the order of a few ms - regardless of whether it's a Debug or Release mode, while on my own local Win10 the println!() easily takes around 100+ ms, with the write!() into the StdoutLock<'_> is taking 1.25x to 1.5x+ as much?
That last bit is particularly surprising. Shouldn't println!() always be slower?
1 post - 1 participant
🏷️ rust_feed