I wrote a solution for the parentheses generation problem. If I use
print! without a newline, my code is 3x
slower faster than when I use
print!() with a newline. I looked at the flamegraphs, and the code with the newlines has a much wider print section. I tried instantiating and locking
stdout myself and pass around, but that changed nothing.
Can any one offer any advice? I’ve put the code on the playground and you can run it on your own machine with
$ echo 14 | cargo run --release -q. (Try changing line 10.)
I use Rust 1.36 on Ubuntu 16.04.
Edit: s/slower/faster. Pretty important detail!