jimporter / mettle

A C++20 unit test framework
https://jimporter.github.io/mettle
BSD 3-Clause "New" or "Revised" License
122 stars 12 forks source link

Use constexpr-std::copy for arrays of trivial types in any_capture #39

Closed jimporter closed 4 years ago

jimporter commented 6 years ago

C++20 makes std::copy and friends constexpr, which would probably make for a faster-to-compile implementation of any_capture<T[N]> for trivial types. We should test the perf improvements, but this would especially help with capturing long string literals.

jimporter commented 4 years ago

The (rather obvious) answer here is to just use a for loop rather than worrying about constexpr std::copy. For capturing a 256 KB string, the results are:

 pre-patch: 73.35s user 0.70s system 99% cpu 1:14.06 total
post-patch:  0.05s user 0.01s system 99% cpu 0.067 total

Not bad, I'd say.