Skip to content

Instantly share code, notes, and snippets.

@swigger
Created March 7, 2025 11:00
Show Gist options
  • Save swigger/2d6129df48614d7a80679f1e694304bf to your computer and use it in GitHub Desktop.
Save swigger/2d6129df48614d7a80679f1e694304bf to your computer and use it in GitHub Desktop.
test msvc regex
gcc regex is terrible.
msvc regex is just a joke.
using code from https://github.com/mariomka/regex-benchmark?tab=readme-ov-file#optimized
default: using msvc default <regex> file.
pmr: copy regex header, change all vector into std::pmr::vector
pmr+my allocator: based on pmr,create my own allocator, and set it with std::pmr::set_default_resource
debug: debug version but with _ITERATOR_DEBUG_LEVEL=0
numbers A - B: A is the time of the function, in ms. B is the count of matches. B means right, A means performance.
alloc=XXX in debug version, we can use ucrtbased internal variables to read out the call count to malloc.
that means durring the test , msvc regex calls to malloc over than 380 MILLION times.
default:
3301.39 - 92
4487.88 - 5301
5504.82 - 5
pmr:
3218.16 - 92
4351.39 - 5301
5458.26 - 5
pmr+my allocator:
1610.36 - 92
2060.85 - 5301
2316.87 - 5
boost:
65.1183 - 92
65.4268 - 5301
13.6477 - 5
rust:
4.4834000000000005 - 92
3.1468 - 5301
4.6803 - 5
debug version, default:
111708 - 92
148499 - 5301
173707 - 5
alloc=381146419
debug version, pmr + myallocator:
155301 - 92
206168 - 5301
254886 - 5
alloc=11106
debug version, pmr:
113279 - 92
151737 - 5301
181790 - 5
alloc=381146419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment