Re:Performance comparison: counting words in Python, C/C++, ...
by burntsushi on Monday July 25, 2022 @07:31PM
(#32232347)
I wrote the Rust version and the comments are a reflection of my style and my belief that benchmarks should come with some kind of analysis. The "simple" variant was also intended to demonstrate idiomatic code without a bunch of perf tricks. Nicer error messages in that case is fair game.
Indeed, a naively analysis based on code size without taking comments into account is pretty obviously wrong.
I did not check all files, but noticed that the simple rust code consists of about 60% comments (in terms of bytes), mostly due to a verbose blurb. It also spends about 15% of the non-comment bytes on printing nicer error messages, which is an interesting choice for a micro-benchmark. The simple C and FORTH versions similarly have a lot of comments.
Meanwhile a lot of the other files have very few or no comments.