I was looking for a way to benchmark a piece of code… I came up with 5 libraries that make it very easy
I’m not going to write a tutorial on how to use each one because I would basically be rewriting their documentation sections. What I will do is show you how to get started. As an example I will write a simple benchmark that tests copy constructor of std::string. But first, the libraries:
Catch2 and Nonius are header only libraries; be aware of long compile times Google, Catch2, and Nonius automatically pick the number of runs and iterations for you, which is nice: no guessing how many times you need to run a function you want to benchmark to get a reasonable performance reading.
Google Benchmark:

Catch2:

Hayai:

Celero:

Nonius:

It’ good but is very difficult
why idiotic comments aren’t filtered out by the system, one wonders..