2 ms·
This. "No optimization without quantification" should be pasted up beside Knuth's laws of optimization. Performance testing and profiling will tell you where th
by tjradcliffe 12y ago
This. "No optimization without quantification" should be pasted up beside Knuth's laws of optimization. Performance testing and profiling will tell you where the code is really spending its time. Fix those problems.
The past 20 years have shown us that naive optimization, which was never all that good, breaks completely in modern compilers, which often emit code that is optimized for the underlying architecture in ways that it's difficult for the programmer to anticipate. Like everyone who used to do a lot of hand optimization, in the late 90's I started seeing more and more cases where my clever tricks were making things worse, not better. So you can't just optimize by rote: you have to understand the specific problem you're dealing with.