Test images addition / subtraction performances.
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_CATCH2)
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#define CATCH_CONFIG_RUNNER
#include <catch.hpp>
#include <visp3/core/vpImageTools.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#include "common.hpp"
TEST_CASE("Benchmark vpImageTools::imageAdd()", "[benchmark]") {
"Klimt/Klimt.pgm");
common_tools::fill(I2);
SECTION("Without saturation")
{
const bool saturation = false;
BENCHMARK("Benchmark naive imageAdd() code without saturation") {
common_tools::imageAddRef(I, I2, Iadd, saturation);
return I;
};
BENCHMARK("Benchmark ViSP imageAdd() code without saturation") {
return I;
};
}
SECTION("With saturation")
{
const bool saturation = true;
BENCHMARK("Benchmark naive imageAdd() code with saturation") {
common_tools::imageAddRef(I, I2, Iadd, saturation);
return I;
};
BENCHMARK("Benchmark ViSP imageAdd() code with saturation") {
return I;
};
}
}
TEST_CASE("Benchmark vpImageTools::imageSubtract()", "[benchmark]") {
"Klimt/Klimt.pgm");
common_tools::fill(I2);
SECTION("Without saturation")
{
const bool saturation = false;
BENCHMARK("Benchmark naive imageSub() code without saturation") {
common_tools::imageSubtractRef(I, I2, Isub, saturation);
return I;
};
BENCHMARK("Benchmark ViSP imageSub() code without saturation") {
return I;
};
}
SECTION("With saturation")
{
const bool saturation = true;
BENCHMARK("Benchmark naive imageSub() code with saturation") {
common_tools::imageSubtractRef(I, I2, Isub, saturation);
return I;
};
BENCHMARK("Benchmark ViSP imageSub() code with saturation") {
return I;
};
}
}
int main(int argc, char *argv[])
{
Catch::Session session;
bool runBenchmark = false;
using namespace Catch::clara;
auto cli = session.cli()
| Opt(runBenchmark)
["--benchmark"]
("run benchmark?");
session.cli(cli);
session.applyCommandLine(argc, argv);
if (runBenchmark) {
int numFailed = session.run();
return numFailed;
}
return EXIT_SUCCESS;
}
#else
int main()
{
return 0;
}
#endif