std::wregex EXCEL_CELL_REGEX(L"=\"(.*)\"", std::regex::optimize);
std::wstring text = L"=\"300498\"";
for (int i = 0; i < 981 * 6; i++) {
std::wsmatch match;
std::regex_match(text, match, EXCEL_CELL_REGEX);
}
Above code takes about 9 seconds
boost::wregex EXCEL_CELL_REGEX(L"=\"(.*)\"", boost::regex::optimize);
std::wstring text = L"=\"300498\"";
for (int i = 0; i < 981 * 6; i++) {
boost::wsmatch match;
boost::regex_match(text, match, EXCEL_CELL_REGEX);
}
Above code takes about 1.5 seconds
Those tests are built on Debug configuration.
Do you know why std::regex is so slow? How to optimize the code?
Debug execution times are useless; they are often completely divorced from real-life performance of the Release build. Also, debug times will be extremely system- and compiler-dependent.