Hi,
The code looks fine to me to benchmark the integration time. You might need to consider also the time to construct the TF1 object in case you cannot move it outside your critical code
The use case here would be building an efficient numerical integrator. With this method of benchmarking I’ve managed to get to 1/10 the time of TF1::Integral with equal/more precision (given the integration interval is sufficiently small). I was not sure of the reliability of this code.
Hi,
Instead of TF1 which is not super efficient, you can use directly the Integrator class and construct the class outside your benchmark. This will reflect better the time of integration.
See the code of TF1::IntegralOneDim (ROOT: hist/hist/src/TF1.cxx Source File).
The overhead of using TF1 will be more visible when integrating simple functions. Note also that there are different integration methods available. See ROOT: TF1 Class Reference