feat(core): add a function profiling utilities
Description
Benchmarking some code blocks is easy with the help of FW_PROFILE. However, to obtain accurate results, we are often required to call the code to profile many times, often in a loop. This leads to a good deal of boilerplate code that can be avoided or at least factorized. Furthermore, it upon of the user to compute mean or standard error / deviation.
Proposal
Add a function helper that take a function/lambda, execute it many times (or until a standard deviation is reached) and compute the average elapsed time and the standard error.
Functional specifications / Technical specifications
Something like:
FW_PROFILE_FUNC(
[&]
(std::size_t i)
{
/// some code to profile
my_code_to_call();
},
10, /// At least 10x
"A label to find it in the log",
0.1 /// the error ratio to reach (standard_error / mean)
);
Test plan
- Use it in a unit test, check the returned values...