Yesterday’s post showed that the original C++ version is around 13 times slower than my non-optimized Rust version. Next, I’ll show how to get easily equivalent performance to Rust. One problem that I immediately made out when first seeing the C++ version is that it uses std::regex. std::regex is known to be horribly slow 1. Just replacing the checking of the file name extension with the in-built e.path().extension() != ".txt" speeds up from 373 ms to 52ms!
Crash Reporting If your program is running on more than one machine or is used by others, you probably want to get some insight into when things fail. I believe this is commonly called “Crash Reporting”. Such a crash reporting system will consist of a component to collect individual incidents and of a component to aggregate individual reports. For example, it will group common incidents by stack trace. One public example of this, is Mozilla’s system (Socorro).