Код: Выделить всё
#include
#include
//[.] means that the test won't be run automatically.
//[my_benchmarks] is a freely named tag that can be used to only run those tests.
TEST_CASE("MicroBenchmarks", "[.][my_benchmarks]") {
// Code that is placed here will be run before every benchmark.
// This is useful for setting up the environment.
BENCHMARK_ADVANCED("function_to_measure")(Catch::Benchmark::Chronometer meter) {
//Code outside of the measure block won't be measured
set_up();
//The return of a result inside the measure block
//prevents the optimizer from optimizing the code away
meter.measure([] { return function_to_measure(); });
};
}
Это влияет на результат теста.
Кто-нибудь замечал такое? ?
Я так удивлен, потому что это так часто используется!
Есть ли обходной путь для этой проблемы?
Подробнее здесь: https://stackoverflow.com/questions/791 ... -behaviour