Skip to content

Commit

Permalink
Update perfImageLoadSave.cpp and PerfVisualize.py script to be able t…
Browse files Browse the repository at this point in the history
…o plot image I/O performance numbers.
  • Loading branch information
s-trinh committed Jan 24, 2022
1 parent 440892b commit 5b825df
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 149 deletions.
7 changes: 0 additions & 7 deletions modules/io/src/image/private/vpImageIoBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Description:
<<<<<<< HEAD
* Read/write images.
*
* Authors:
* Eric Marchand
=======
* Backend functions implementation for image I/O operations.
>>>>>>> 557f1beda01f36ca886ec039d0a1a80a7446ca59
*
*****************************************************************************/

Expand Down
200 changes: 104 additions & 96 deletions modules/io/test/perfImageLoadSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,65 +72,61 @@ static std::vector<std::string> backendNamesPng {
};
static int nThreads = 0;

TEST_CASE("Benchmark JPEG image loading", "[benchmark]") {
SECTION("Grayscale") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<vpRGBa> I;

BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::read(I, paths[i] + ".jpg", backends[j]);
return I;
};
}
TEST_CASE("Benchmark grayscale JPEG image loading", "[benchmark]") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<vpRGBa> I;

BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::read(I, paths[i] + ".jpg", backends[j]);
return I;
};
}
}
}
}

TEST_CASE("Benchmark RGBA JPEG image loading", "[benchmark]") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<unsigned char> I;

SECTION("vpRGBa") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<unsigned char> I;

BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::read(I, paths[i] + ".jpg", backends[j]);
return I;
};
}
BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::read(I, paths[i] + ".jpg", backends[j]);
return I;
};
}
}
}
}

TEST_CASE("Benchmark PNG image loading", "[benchmark]") {
SECTION("Grayscale") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<vpRGBa> I;

BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::read(I, paths[i] + ".png", backends[j]);
return I;
};
}
TEST_CASE("Benchmark grayscale PNG image loading", "[benchmark]") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<vpRGBa> I;

BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::read(I, paths[i] + ".png", backends[j]);
return I;
};
}
}
}
}

SECTION("vpRGBa") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<unsigned char> I;

BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::read(I, paths[i] + ".png", backends[j]);
return I;
};
}
TEST_CASE("Benchmark RGBA PNG image loading", "[benchmark]") {
for (size_t i = 0; i < paths.size(); i++) {
SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
vpImage<unsigned char> I;

BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::read(I, paths[i] + ".png", backends[j]);
return I;
};
}
}
}
Expand All @@ -144,83 +140,95 @@ std::string tmp_dir = "/tmp/";
std::string tmp_dir = "C:/Temp/";
#endif

TEST_CASE("Benchmark JPEG image saving", "[benchmark]") {
TEST_CASE("Benchmark grayscale JPEG image saving", "[benchmark]") {
vpIoTools::getUserName(username);
vpIoTools::makeDirectory(tmp_dir + username);
directory_filename_tmp = tmp_dir + username + "/vpIoTools_perfImageLoadSave_" + vpTime::getDateTime("%Y-%m-%d_%H.%M.%S");
vpIoTools::makeDirectory(directory_filename_tmp);
REQUIRE(vpIoTools::checkDirectory(directory_filename_tmp));

SECTION("Grayscale") {
for (size_t i = 0; i < paths.size(); i++) {
vpImage<unsigned char> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.jpg", backends[j]);
return I;
};
}
for (size_t i = 0; i < paths.size(); i++) {
vpImage<unsigned char> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.jpg", backends[j]);
return I;
};
}
}
}

SECTION("vpRGBa") {
for (size_t i = 0; i < paths.size(); i++) {
vpImage<vpRGBa> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.jpg", backends[j]);
return I;
};
}
REQUIRE(vpIoTools::remove(directory_filename_tmp));
}

TEST_CASE("Benchmark RGBA JPEG image saving", "[benchmark]") {
vpIoTools::getUserName(username);
vpIoTools::makeDirectory(tmp_dir + username);
directory_filename_tmp = tmp_dir + username + "/vpIoTools_perfImageLoadSave_" + vpTime::getDateTime("%Y-%m-%d_%H.%M.%S");
vpIoTools::makeDirectory(directory_filename_tmp);
REQUIRE(vpIoTools::checkDirectory(directory_filename_tmp));

for (size_t i = 0; i < paths.size(); i++) {
vpImage<vpRGBa> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesJpeg[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.jpg", backends[j]);
return I;
};
}
}
}

REQUIRE(vpIoTools::remove(directory_filename_tmp));
}

TEST_CASE("Benchmark PNG image saving", "[benchmark]") {
TEST_CASE("Benchmark grayscale PNG image saving", "[benchmark]") {
vpIoTools::getUserName(username);
vpIoTools::makeDirectory(tmp_dir + username);
directory_filename_tmp = tmp_dir + username + "/vpIoTools_perfImageLoadSave_" + vpTime::getDateTime("%Y-%m-%d_%H.%M.%S");
vpIoTools::makeDirectory(directory_filename_tmp);
REQUIRE(vpIoTools::checkDirectory(directory_filename_tmp));

SECTION("Grayscale") {
for (size_t i = 0; i < paths.size(); i++) {
vpImage<unsigned char> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.png", backends[j]);
return I;
};
}
for (size_t i = 0; i < paths.size(); i++) {
vpImage<unsigned char> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.png", backends[j]);
return I;
};
}
}
}

SECTION("vpRGBa") {
for (size_t i = 0; i < paths.size(); i++) {
vpImage<vpRGBa> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.png", backends[j]);
return I;
};
}
REQUIRE(vpIoTools::remove(directory_filename_tmp));
}

TEST_CASE("Benchmark RGBA PNG image saving", "[benchmark]") {
vpIoTools::getUserName(username);
vpIoTools::makeDirectory(tmp_dir + username);
directory_filename_tmp = tmp_dir + username + "/vpIoTools_perfImageLoadSave_" + vpTime::getDateTime("%Y-%m-%d_%H.%M.%S");
vpIoTools::makeDirectory(directory_filename_tmp);
REQUIRE(vpIoTools::checkDirectory(directory_filename_tmp));

for (size_t i = 0; i < paths.size(); i++) {
vpImage<vpRGBa> I;
vpImageIo::read(I, paths[i] + ".png");

SECTION(names[i]) {
for (size_t j = 0; j < backends.size(); j++) {
BENCHMARK(backendNamesPng[j] + " backend") {
vpImageIo::write(I, directory_filename_tmp + "/ViSP_tmp_perf_write.png", backends[j]);
return I;
};
}
}
}
Expand Down
Loading

0 comments on commit 5b825df

Please sign in to comment.