mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:58:12 +00:00
test-jpeg-roundtrip: Print summary statistics at the end
This commit is contained in:
parent
8ef3310525
commit
25efe65a83
1 changed files with 26 additions and 12 deletions
|
@ -51,32 +51,46 @@ static ErrorOr<float> perceived_distance_in_sRGB(Gfx::Color a, Gfx::Color b)
|
||||||
return DeltaE(TRY(sRGB->to_lab(array_a)), TRY(sRGB->to_lab(array_b)));
|
return DeltaE(TRY(sRGB->to_lab(array_a)), TRY(sRGB->to_lab(array_b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ErrorOr<void> test(Gfx::Color color)
|
struct Stats {
|
||||||
|
float max_delta {};
|
||||||
|
int max_number_of_iterations {};
|
||||||
|
};
|
||||||
|
|
||||||
|
static ErrorOr<void> test(Gfx::Color color, Stats& stats)
|
||||||
{
|
{
|
||||||
auto fixpoint = TRY(compute_fixpoint(color));
|
auto fixpoint = TRY(compute_fixpoint(color));
|
||||||
|
|
||||||
float perceived_distance = TRY(perceived_distance_in_sRGB(color, fixpoint.fixpoint));
|
float perceived_distance = TRY(perceived_distance_in_sRGB(color, fixpoint.fixpoint));
|
||||||
|
|
||||||
outln("color {} converges to {} after saving {} times, delta {}", color, fixpoint.fixpoint, fixpoint.number_of_iterations, perceived_distance);
|
outln("color {} converges to {} after saving {} times, delta {}", color, fixpoint.fixpoint, fixpoint.number_of_iterations, perceived_distance);
|
||||||
|
|
||||||
|
stats.max_delta = max(stats.max_delta, perceived_distance);
|
||||||
|
stats.max_number_of_iterations = max(stats.max_number_of_iterations, fixpoint.number_of_iterations);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments)
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
TRY(test(Gfx::Color::Red));
|
Stats stats;
|
||||||
TRY(test(Gfx::Color::Green));
|
|
||||||
TRY(test(Gfx::Color::Blue));
|
|
||||||
|
|
||||||
TRY(test(Gfx::Color::MidRed));
|
TRY(test(Gfx::Color::Red, stats));
|
||||||
TRY(test(Gfx::Color::MidGreen));
|
TRY(test(Gfx::Color::Green, stats));
|
||||||
TRY(test(Gfx::Color::MidBlue));
|
TRY(test(Gfx::Color::Blue, stats));
|
||||||
|
|
||||||
TRY(test(Gfx::Color::Cyan));
|
TRY(test(Gfx::Color::MidRed, stats));
|
||||||
TRY(test(Gfx::Color::Magenta));
|
TRY(test(Gfx::Color::MidGreen, stats));
|
||||||
TRY(test(Gfx::Color::Yellow));
|
TRY(test(Gfx::Color::MidBlue, stats));
|
||||||
|
|
||||||
TRY(test(Gfx::Color::Black));
|
TRY(test(Gfx::Color::Cyan, stats));
|
||||||
TRY(test(Gfx::Color::White));
|
TRY(test(Gfx::Color::Magenta, stats));
|
||||||
|
TRY(test(Gfx::Color::Yellow, stats));
|
||||||
|
|
||||||
|
TRY(test(Gfx::Color::Black, stats));
|
||||||
|
TRY(test(Gfx::Color::White, stats));
|
||||||
|
|
||||||
|
outln();
|
||||||
|
outln("max delta {}, max number of iterations {}", stats.max_delta, stats.max_number_of_iterations);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue