Test images addition / subtraction performances.
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_CATCH2)
#include "common.hpp"
#include <catch_amalgamated.hpp>
#include <visp3/core/vpImageTools.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/io/vpImageIo.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
TEST_CASE("Benchmark vpImageTools::imageAdd()", "[benchmark]")
{
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]")
{
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;
auto cli = session.cli()
| Catch::Clara::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 EXIT_SUCCESS; }
#endif
static void read(vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
unsigned int getWidth() const
unsigned int getHeight() const