-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(tiledit): add benchmark target to check for performance regress…
…ions - Enable LTO for release builds for performance reasons - Flatten SircImatge pixelData to a 1D array to make it easier to work with in STL algorithms - General refactoring to pull out duplicated logic
- Loading branch information
1 parent
aea8f3e
commit 8bc442c
Showing
22 changed files
with
3,792 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
libs/shared/tests/catch2/* | ||
libs/shared/benchmarks/nanobench/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
libs/shared/tests/catch2/* | ||
libs/shared/benchmarks/nanobench/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include "nanobench/nanobench.h" | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
#include "testconfig.h" | ||
#include <imageloader.hpp> | ||
#include <mediancutquantizer.hpp> | ||
#include <rgbaadapter.hpp> | ||
#include <sircimage.hpp> | ||
|
||
SircImage setupBenchmark(const std::filesystem::path &inputPath) { | ||
const std::filesystem::path testRootPath(BENCHMARK_ROOT); | ||
|
||
const auto inputPixelData = | ||
ImageLoader::loadImageFromPng((testRootPath / inputPath).c_str()); | ||
return RgbaAdapter::rgbaToSircImage(inputPixelData); | ||
} | ||
|
||
int main() { | ||
const auto pixelArtBackgroundImage = setupBenchmark( | ||
std::filesystem::path("resources/pixel_art_background.png")); | ||
const auto gradientImage = | ||
setupBenchmark(std::filesystem::path("resources/gradient.png")); | ||
const auto redfloweringGumImage = | ||
setupBenchmark(std::filesystem::path("resources/red_flowering_gum.png")); | ||
const auto quantizer = MedianCutQuantizer(); | ||
constexpr int epochs = 500; | ||
|
||
std::ofstream pixelArtBackground2BppPyPerf("pixel_art_background-2bpp.json"); | ||
std::ofstream pixelArtBackground4BppPyPerf("pixel_art_background-4bpp.json"); | ||
std::ofstream gradient2BppPyPerf("gradient-2bpp.json"); | ||
std::ofstream gradient4BppPyPerf("gradient-4bpp.json"); | ||
std::ofstream redFloweringGum2BppPyPerf("red_flowering_gum-2bpp.json"); | ||
std::ofstream redFloweringGum4BppPyPerf("red_flowering_gum-4bpp.json"); | ||
std::ofstream redFloweringGum8BppPyPerf("red_flowering_gum-8bpp.json"); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (pixel_art_background/2bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
pixelArtBackgroundImage, PaletteReductionBpp::TwoBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), | ||
pixelArtBackground2BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (pixel_art_background/4bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
pixelArtBackgroundImage, PaletteReductionBpp::FourBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), | ||
pixelArtBackground4BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (gradient/2bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
gradientImage, PaletteReductionBpp::TwoBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), gradient2BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (gradient/4bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
gradientImage, PaletteReductionBpp::FourBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), gradient4BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (red_flowering_gum/2bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
redfloweringGumImage, PaletteReductionBpp::TwoBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), | ||
redFloweringGum2BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (red_flowering_gum/4bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
redfloweringGumImage, PaletteReductionBpp::FourBpp)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), | ||
redFloweringGum4BppPyPerf); | ||
|
||
ankerl::nanobench::Bench() | ||
.epochs(epochs) | ||
.run("Quantizes a real test image correctly (red_flowering_gum/8bpp)", | ||
[&] { | ||
ankerl::nanobench::doNotOptimizeAway(quantizer.quantize( | ||
redfloweringGumImage, PaletteReductionBpp::None)); | ||
}) | ||
.render(ankerl::nanobench::templates::pyperf(), | ||
redFloweringGum8BppPyPerf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
conf = configuration_data() | ||
conf.set_quoted('BENCHMARK_ROOT', meson.source_root() / 'libs/shared/benchmarks') | ||
configure_file( | ||
output : 'testconfig.h', | ||
configuration : conf | ||
) | ||
|
||
nanobench_lib = library( | ||
'nanobench', | ||
['./nanobench/nanobench.cpp'], | ||
version : '4.3.11', | ||
) | ||
|
||
|
||
benchmark( | ||
'AllBenchmarks', | ||
executable( | ||
'benchmarks', | ||
['benchmarks.cpp'], | ||
include_directories : shared_library_include_files, | ||
link_with : [nanobench_lib, shared_lib], | ||
), | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#define ANKERL_NANOBENCH_IMPLEMENT | ||
|
||
#include "./nanobench.h" |
Oops, something went wrong.