Re:Effortless Performance Improvements in C++: std:unordered...
by klaussilveira on Thursday March 02, 2023 @01:35PM
(#34999793)
Going step by step, slowly tackling the issues while also showing the reason behind why it is optimized, is a great way to teach. Congrats on mentorship skills!
The operations on the strings are subtly expensive and I was expecting to see them above the accesses to the maps in the perf report. Now they were not and I address the problems in the order of this report, so we will have to wait a bit to discuss them. The intent is also to unroll a scenario of optimization for the reader: measure to get insight, try something, measure again, decide.
If you have the time and the motivation I would love to see a fast but not super optimized version of this program. I tried to keep using the standard library and not going into cryptic code (i.e. trying to keep the code clear for an average programmer), and I stopped when the performance gain became very small, but I am pretty sure we can get better performance if we push further.