3 ms·
Update: I wrapped the locked stdout handle in a BufWriter and now the rust version is >25% faster than the C++ version in all cases. I didn't think there was r
by usefulcat 8y ago
Update: I wrapped the locked stdout handle in a BufWriter and now the rust version is >25% faster than the C++ version in all cases.
I didn't think there was room for that much improvement; I'm really impressed.
- steveklabnik 8y agoAwesome! Glad you got it sorted. Those two things are always footguns...
- gnuvince 8y agoIf you have a blog, that would make for an amazing entry, going from 50% slower to 25% faster. Edit: HOLY CRAP! I have a program written in Rust, ppbert[1], and I just tried wrapping my StdoutLock object in a BufWriter, and I improved the performance of my pretty-printing by a factor of 2x! I knew to use BufReader for files, I didn't know it was helpful for stdin and stdout! Thank you _so much_ for sharing your experience, I've certainly benefited! Benchmark #1: ppbert -2 *.bert2 Time (mean ± σ): 3.816 s ± 0.115 s [User: 2.494 s, System: 1.321 s] Range (min … max): 3.688 s … 4.028 s Benchmark #2: ppbert-dev -2 *.bert2 Time (mean ± σ): 1.728 s ± 0.045 s [User: 1.493 s, System: 0.234 s] Range (min … max): 1.678 s … 1.843 s Summary 'ppbert-dev -2 *.bert2' ran 2.21x faster than 'ppbert -2 *.bert2' [1] https://github.com/gnuvince/ppbert https://github.com/gnuvince/ppbert