mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
Tests: Add benchmarks for JPEGLoader
I'm the author of the image.
This commit is contained in:
parent
b746d324cf
commit
2812ef246d
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/2812ef246d Pull-request: https://github.com/SerenityOS/serenity/pull/18162 Reviewed-by: https://github.com/linusg
3 changed files with 49 additions and 0 deletions
48
Tests/LibGfx/BenchmarkJPEGLoader.cpp
Normal file
48
Tests/LibGfx/BenchmarkJPEGLoader.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGfx/ImageFormats/JPEGLoader.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
# define TEST_INPUT(x) ("/usr/Tests/LibGfx/test-inputs/" x)
|
||||
#else
|
||||
# define TEST_INPUT(x) ("test-inputs/" x)
|
||||
#endif
|
||||
|
||||
// FIXME: Enable formatting when the patch will be mainstream
|
||||
// https://github.com/llvm/llvm-project/commit/fd86789962964a98157e8159c3d95cdc241942e3
|
||||
// clang-format off
|
||||
auto small_image = Core::File::open(TEST_INPUT("rgb24.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();
|
||||
auto big_image = Core::File::open(TEST_INPUT("big_image.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();
|
||||
auto rgb_image = Core::File::open(TEST_INPUT("rgb_components.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();
|
||||
auto several_scans = Core::File::open(TEST_INPUT("several_scans.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();
|
||||
// clang-format on
|
||||
|
||||
BENCHMARK_CASE(small_image)
|
||||
{
|
||||
auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(small_image));
|
||||
MUST(plugin_decoder->frame(0));
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(big_image)
|
||||
{
|
||||
auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(big_image));
|
||||
MUST(plugin_decoder->frame(0));
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(rgb_image)
|
||||
{
|
||||
auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(rgb_image));
|
||||
MUST(plugin_decoder->frame(0));
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(several_scans)
|
||||
{
|
||||
auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(several_scans));
|
||||
MUST(plugin_decoder->frame(0));
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
set(TEST_SOURCES
|
||||
BenchmarkGfxPainter.cpp
|
||||
BenchmarkJPEGLoader.cpp
|
||||
TestFontHandling.cpp
|
||||
TestICCProfile.cpp
|
||||
TestImageDecoder.cpp
|
||||
|
|
BIN
Tests/LibGfx/test-inputs/big_image.jpg
Normal file
BIN
Tests/LibGfx/test-inputs/big_image.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 MiB |
Loading…
Reference in a new issue