Truly independent web browser
LibTest: Remove benchmark cases and benchmark support
Aliaksandr Kalenik3e807d01e07b
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.ymlindex 658f38d5801..5703eb6593e 100644--- a/.github/workflows/build-and-test.yml+++ b/.github/workflows/build-and-test.yml@@ -150,15 +150,11 @@ jobs:export ASAN_OPTIONS="log_path=\"${GITHUB_WORKSPACE}/Build/asan.log\""export UBSAN_OPTIONS="log_path=\"${GITHUB_WORKSPACE}/Build/ubsan.log\""ctest --preset ${{ inputs.build_preset }} --parallel --output-on-failure -E 'LibWebAccessibilityBridge|AccessibilityBridgeMac' --test-dir Build --timeout 1800- env:- TESTS_ONLY: 1- name: Testif: ${{ inputs.build_preset != 'Fuzzers' && inputs.build_preset != 'All_Debug' && inputs.build_preset != 'Sanitizer' }}working-directory: ${{ github.workspace }}run: ctest --parallel --output-on-failure -E 'LibWebAccessibilityBridge|AccessibilityBridgeMac' --test-dir Build --timeout 1800- env:- TESTS_ONLY: 1# The AT-SPI2 tests need a Linux build that is neither Sanitizer nor All_Debug:# - Sanitizer's ASan-instrumented Qt-on-XCB hits a buffer overflow in libxkbcommon-x11.@@ -169,8 +165,6 @@ jobs:if: ${{ inputs.os_name == 'Linux' && inputs.build_preset == 'Release' }}working-directory: ${{ github.workspace }}run: ctest --output-on-failure --no-tests=error --test-dir Build -R LibWebAccessibilityBridge --timeout 1800- env:- TESTS_ONLY: 1- name: Upload LibWeb Test Artifactsif: ${{ always() && inputs.build_preset != 'Fuzzers' && inputs.build_preset != 'All_Debug' }}diff --git a/Libraries/LibTest/TestCase.h b/Libraries/LibTest/TestCase.hindex 7c9724a20e7..e1aa6dce723 100644--- a/Libraries/LibTest/TestCase.h+++ b/Libraries/LibTest/TestCase.h@@ -32,15 +32,13 @@ inline void run_with_randomness_source(Randomized::RandomnessSource source, Testclass TEST_API TestCase : public RefCounted<TestCase> {public:- TestCase(ByteString name, ByteString source, TestFunction&& function, bool is_benchmark)+ TestCase(ByteString name, ByteString source, TestFunction&& function): m_name(move(name)), m_source(move(source)), m_function(move(function))- , m_is_benchmark(is_benchmark){}- bool is_benchmark() const { return m_is_benchmark; }ByteString const& name() const { return m_name; }ByteString const& source() const { return m_source; }TestFunction const& func() const { return m_function; }@@ -100,14 +98,13 @@ public:}// All randomized_runs() values generated + passed the test.};- return make_ref_counted<TestCase>(move(name), move(source), move(test_case_function), false);+ return make_ref_counted<TestCase>(move(name), move(source), move(test_case_function));}private:ByteString m_name;ByteString m_source;TestFunction m_function;- bool m_is_benchmark;};// Helper to hide implementation of TestSuite from users@@ -125,22 +122,14 @@ TEST_API void set_suite_setup_function(ByteString const& source, Function<void()static void __setup()// Registrations have internal linkage so different source files may use the same case names.-#define TEST_CASE(x) \- static void __test_##x(); \- [[maybe_unused]] static auto const __test_registration_##x = [] { \- ::Test::add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __FILE__, __test_##x, false))); \- return 0; \- }(); \+#define TEST_CASE(x) \+ static void __test_##x(); \+ [[maybe_unused]] static auto const __test_registration_##x = [] { \+ ::Test::add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __FILE__, __test_##x))); \+ return 0; \+ }(); \static void __test_##x()-#define BENCHMARK_CASE(x) \- static void __benchmark_##x(); \- [[maybe_unused]] static auto const __benchmark_registration_##x = [] { \- ::Test::add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __FILE__, __benchmark_##x, true))); \- return 0; \- }(); \- static void __benchmark_##x()-#define RANDOMIZED_TEST_CASE(x) \static void __randomized_test_##x(); \[[maybe_unused]] static auto const __randomized_registration_##x = [] { \diff --git a/Libraries/LibTest/TestSuite.cpp b/Libraries/LibTest/TestSuite.cppindex 8af285e5ca4..406794eec16 100644--- a/Libraries/LibTest/TestSuite.cpp+++ b/Libraries/LibTest/TestSuite.cpp@@ -14,7 +14,6 @@#include <LibTest/Macros.h>#include <LibTest/TestResult.h>#include <LibTest/TestSuite.h>-#include <math.h>namespace Test {@@ -119,22 +118,17 @@ int TestSuite::main(ByteString const& suite_name, Span<StringView> arguments)Core::ArgsParser args_parser;- bool do_tests_only = getenv("TESTS_ONLY") != nullptr;- bool do_benchmarks_only = false;bool do_list_cases = false;StringView search_string = "*"sv;StringView selected_suite;- args_parser.add_option(do_tests_only, "Only run tests.", "tests");- args_parser.add_option(do_benchmarks_only, "Only run benchmarks.", "bench");- args_parser.add_option(m_benchmark_repetitions, "Number of times to repeat each benchmark (default 1)", "benchmark_repetitions", 0, "N");args_parser.add_option(m_randomized_runs, "Number of times to run each RANDOMIZED_TEST_CASE (default 100)", "randomized_runs", 0, "RUNS");args_parser.add_option(do_list_cases, "List available test cases.", "list");args_parser.add_option(selected_suite, "Only run cases from this suite.", "suite", 0, "SUITE");args_parser.add_positional_argument(search_string, "Only run matching cases.", "pattern", Core::ArgsParser::Required::No);args_parser.parse(arguments);- auto const& matching_tests = find_cases(search_string, !do_benchmarks_only, !do_tests_only, selected_suite);+ auto const& matching_tests = find_cases(search_string, selected_suite);if (do_list_cases) {outln("Available cases for {}:", suite_name);@@ -198,7 +192,7 @@ int TestSuite::main(ByteString const& suite_name, Span<StringView> arguments)return run(matching_tests);}-Vector<NonnullRefPtr<TestCase>> TestSuite::find_cases(ByteString const& search, bool find_tests, bool find_benchmarks, StringView suite)+Vector<NonnullRefPtr<TestCase>> TestSuite::find_cases(ByteString const& search, StringView suite){Vector<NonnullRefPtr<TestCase>> matches;for (auto& t : m_cases) {@@ -210,13 +204,6 @@ Vector<NonnullRefPtr<TestCase>> TestSuite::find_cases(ByteString const& search,continue;}- if (!find_tests && !t->is_benchmark()) {- continue;- }- if (!find_benchmarks && t->is_benchmark()) {- continue;- }-matches.append(t);}return matches;@@ -227,98 +214,45 @@ int TestSuite::run(Vector<NonnullRefPtr<TestCase>> const& tests)size_t test_count = 0;size_t test_passed_count = 0;size_t test_failed_count = 0;- size_t benchmark_count = 0;- size_t benchmark_passed_count = 0;- size_t benchmark_failed_count = 0;TestElapsedTimer global_timer;for (auto const& t : tests) {- auto const test_type = t->is_benchmark() ? "benchmark" : "test";- auto const repetitions = t->is_benchmark() ? m_benchmark_repetitions : 1;-- warnln("Running {} '{}'.", test_type, t->name());+ warnln("Running test '{}'.", t->name());m_current_test_result = TestResult::NotRun;enable_reporting();- AK::Duration total_time;- u64 sum_of_squared_times = 0;- AK::Duration min_time = AK::Duration::max();- AK::Duration max_time;-- for (u64 i = 0; i < repetitions; ++i) {- TestElapsedTimer timer;- t->func()();- auto const iteration_time = timer.elapsed();- auto const iteration_ms = iteration_time.to_milliseconds();- total_time += iteration_time;- sum_of_squared_times += iteration_ms * iteration_ms;- min_time = min(min_time, iteration_time);- max_time = max(max_time, iteration_time);-- // Non-randomized tests don't touch the test result when passing.- if (m_current_test_result == TestResult::NotRun)- m_current_test_result = TestResult::Passed;- }+ TestElapsedTimer timer;+ t->func()();+ auto const test_time = timer.elapsed();- auto const total_time_ms = total_time.to_milliseconds();+ // Non-randomized tests don't touch the test result when passing.+ if (m_current_test_result == TestResult::NotRun)+ m_current_test_result = TestResult::Passed;- if (repetitions != 1) {- double average = total_time_ms / static_cast<double>(repetitions);- double average_squared = average * average;- double standard_deviation = sqrt((sum_of_squared_times + repetitions * average_squared - 2 * total_time_ms * average) / (repetitions - 1));+ dbgln("{} test '{}' in {}ms", test_result_to_string(m_current_test_result), t->name(), test_time.to_milliseconds());- dbgln("{} {} '{}' on average in {:.1f}±{:.1f}ms (min={}ms, max={}ms, total={}ms)",- test_result_to_string(m_current_test_result), test_type, t->name(),- average,- standard_deviation,- min_time.to_milliseconds(),- max_time.to_milliseconds(),- total_time_ms);- } else {- dbgln("{} {} '{}' in {}ms", test_result_to_string(m_current_test_result), test_type, t->name(), total_time_ms);- }+ m_test_time += test_time;+ test_count++;- if (t->is_benchmark()) {- m_bench_time += total_time;- benchmark_count++;-- switch (m_current_test_result) {- case TestResult::Passed:- benchmark_passed_count++;- break;- case TestResult::Failed:- benchmark_failed_count++;- break;- default:- break;- }- } else {- m_test_time += total_time;- test_count++;-- switch (m_current_test_result) {- case TestResult::Passed:- test_passed_count++;- break;- case TestResult::Failed:- test_failed_count++;- break;- default:- break;- }+ switch (m_current_test_result) {+ case TestResult::Passed:+ test_passed_count++;+ break;+ case TestResult::Failed:+ test_failed_count++;+ break;+ default:+ break;}}- auto const runtime = m_test_time + m_bench_time;auto const elapsed = global_timer.elapsed();- dbgln("Finished {} tests and {} benchmarks in {}ms ({}ms tests, {}ms benchmarks, {}ms other).",+ dbgln("Finished {} tests in {}ms ({}ms tests, {}ms other).",test_count,- benchmark_count,elapsed.to_milliseconds(),m_test_time.to_milliseconds(),- m_bench_time.to_milliseconds(),- (elapsed - runtime).to_milliseconds());+ (elapsed - m_test_time).to_milliseconds());if (test_count != 0) {if (test_passed_count == test_count) {@@ -330,19 +264,9 @@ int TestSuite::run(Vector<NonnullRefPtr<TestCase>> const& tests)}}- if (benchmark_count != 0) {- if (benchmark_passed_count == benchmark_count) {- dbgln("All {} benchmarks passed.", benchmark_count);- } else if (benchmark_passed_count + benchmark_failed_count == benchmark_count) {- dbgln("Out of {} benchmarks, {} passed and {} failed.", benchmark_count, benchmark_passed_count, benchmark_failed_count);- } else {- dbgln("Out of {} benchmarks, {} passed, {} failed and {} didn't finish for other reasons.", benchmark_count, benchmark_passed_count, benchmark_failed_count, benchmark_count - benchmark_passed_count - benchmark_failed_count);- }- }-// We have multiple TestResults, all except for Passed being "bad".// Let's get a count of them:- return (int)(test_count - test_passed_count + benchmark_count - benchmark_passed_count);+ return (int)(test_count - test_passed_count);}} // namespace Testdiff --git a/Libraries/LibTest/TestSuite.h b/Libraries/LibTest/TestSuite.hindex e46f9b3b145..d26d8a45cc1 100644--- a/Libraries/LibTest/TestSuite.h+++ b/Libraries/LibTest/TestSuite.h@@ -41,7 +41,7 @@ public:int run(Vector<NonnullRefPtr<TestCase>> const&);int main(ByteString const& suite_name, Span<StringView> arguments);- Vector<NonnullRefPtr<TestCase>> find_cases(ByteString const& search, bool find_tests, bool find_benchmarks, StringView suite = {});+ Vector<NonnullRefPtr<TestCase>> find_cases(ByteString const& search, StringView suite = {});void add_case(NonnullRefPtr<TestCase> const& test_case){m_cases.append(test_case);@@ -72,9 +72,7 @@ private:static TestSuite* s_global;Vector<NonnullRefPtr<TestCase>> m_cases;AK::Duration m_test_time;- AK::Duration m_bench_time;ByteString m_suite_name;- u64 m_benchmark_repetitions = 1;u64 m_randomized_runs = 100;HashMap<ByteString, Function<void()>> m_setups;TestResult m_current_test_result = TestResult::NotRun;diff --git a/Tests/AK/TestByteBuffer.cpp b/Tests/AK/TestByteBuffer.cppindex 12f9a19a447..2c392eb8d0a 100644--- a/Tests/AK/TestByteBuffer.cpp+++ b/Tests/AK/TestByteBuffer.cpp@@ -63,14 +63,6 @@ TEST_CASE(zero_fill_new_elements_on_growth)EXPECT_EQ(buffer.span(), (Array<u8, 10> { 2, 2, 2, 2, 2, 2, 2, 2, 0, 0 }));}-BENCHMARK_CASE(append)-{- ByteBuffer bb;- for (size_t i = 0; i < 1000000; ++i) {- bb.append(static_cast<u8>(i));- }-}-/** FIXME: These `negative_*` tests should cause precisely one compilation error* each, and always for the specified reason. Currently we do not have a harnessdiff --git a/Tests/AK/TestCharacterTypes.cpp b/Tests/AK/TestCharacterTypes.cppindex 156619b9b95..07357947c0c 100644--- a/Tests/AK/TestCharacterTypes.cpp+++ b/Tests/AK/TestCharacterTypes.cpp@@ -178,21 +178,6 @@ TEST_CASE(parse_ascii_hex_digit)EXPECT_DEATH("parsing invalid ASCII hex digit", parse_ascii_hex_digit('g'));}-BENCHMARK_CASE(is_ascii)-{- compare_bool_output_over(UNICODE, isascii, is_ascii);-}--BENCHMARK_CASE(to_ascii_lowercase_unicode)-{- compare_value_output_over(UNICODE, tolower, to_ascii_lowercase);-}--BENCHMARK_CASE(to_ascii_uppercase_unicode)-{- compare_value_output_over(UNICODE, toupper, to_ascii_uppercase);-}-// NOTE: This would take too long to run exhaustively. Let's at least run random subsets of it!RANDOMIZED_TEST_CASE(is_ascii_unicode){diff --git a/Tests/AK/TestHashFunctions.cpp b/Tests/AK/TestHashFunctions.cppindex 4b44a150fbd..3b8fac5d20e 100644--- a/Tests/AK/TestHashFunctions.cpp+++ b/Tests/AK/TestHashFunctions.cpp@@ -53,21 +53,3 @@ TEST_CASE(constexpr_ptr_hash)// "ptr_hash" test binds the result.static_assert(ptr_hash(FlatPtr(42)));}--template<typename HashFunction>-requires(IsCallableWithArguments<HashFunction, unsigned, u64>)-static void run_benchmark(HashFunction hash_function)-{- for (size_t i = 0; i < 1'000'000; ++i) {- auto a = hash_function(i);- AK::taint_for_optimizer(a);- auto b = hash_function(i);- AK::taint_for_optimizer(b);- EXPECT_EQ(a, b);- }-}--BENCHMARK_CASE(deterministic_hash)-{- run_benchmark(u64_hash);-}diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cppindex 447a15baedd..287bb7db4f4 100644--- a/Tests/AK/TestHashTable.cpp+++ b/Tests/AK/TestHashTable.cpp@@ -613,134 +613,3 @@ TEST_CASE(non_trivially_relocatable_bucket_relocation_ordered)for (auto& entry : table)EXPECT(AddressTrackingType::s_live_instances.contains(&entry));}--static constexpr int ITERATION_COUNT = 100;--struct NonTrivialValue {- int value;- Vector<int> data;-- explicit NonTrivialValue(int v)- : value(v)- , data({ v, v + 1, v + 2 })- {- }-- NonTrivialValue(NonTrivialValue&& other)- : value(other.value)- , data(move(other.data))- {- }-- NonTrivialValue& operator=(NonTrivialValue&& other)- {- if (this != &other) {- value = other.value;- data = move(other.data);- }- return *this;- }-- NonTrivialValue(NonTrivialValue const&) = delete;- NonTrivialValue& operator=(NonTrivialValue const&) = delete;-- bool operator==(NonTrivialValue const& other) const { return value == other.value; }-};--static_assert(!IsTriviallyRelocatable<NonTrivialValue>);--namespace AK {--template<>-struct Traits<NonTrivialValue> : public DefaultTraits<NonTrivialValue> {- static unsigned hash(NonTrivialValue const& v) { return u32_hash(v.value); }-};--}--BENCHMARK_CASE(insert_remove_int)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- HashTable<int> table;- for (int i = 0; i < 10'000; ++i)- table.set(i);- for (int i = 0; i < 10'000; i += 2)- table.remove(i);- for (int i = 10'000; i < 15'000; ++i)- table.set(i);- }-}--BENCHMARK_CASE(insert_remove_int_ordered)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- OrderedHashTable<int> table;- for (int i = 0; i < 10'000; ++i)- table.set(i);- for (int i = 0; i < 10'000; i += 2)- table.remove(i);- for (int i = 10'000; i < 15'000; ++i)- table.set(i);- }-}--BENCHMARK_CASE(insert_remove_non_trivial)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- HashTable<NonTrivialValue> table;- for (int i = 0; i < 10'000; ++i)- table.set(NonTrivialValue(i));- for (int i = 0; i < 10'000; i += 2)- table.remove(NonTrivialValue(i));- for (int i = 10'000; i < 15'000; ++i)- table.set(NonTrivialValue(i));- }-}--BENCHMARK_CASE(insert_remove_non_trivial_ordered)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- OrderedHashTable<NonTrivialValue> table;- for (int i = 0; i < 10'000; ++i)- table.set(NonTrivialValue(i));- for (int i = 0; i < 10'000; i += 2)- table.remove(NonTrivialValue(i));- for (int i = 10'000; i < 15'000; ++i)- table.set(NonTrivialValue(i));- }-}--// Increase the likelihoood of collisions to stress the collision resolution code paths.-struct CollidingIntTraits : public DefaultTraits<int> {- static unsigned hash(int value) { return u32_hash(value) & 0xF; }-};--struct CollidingNonTrivialTraits : public DefaultTraits<NonTrivialValue> {- static unsigned hash(NonTrivialValue const& v) { return u32_hash(v.value) & 0xF; }-};--BENCHMARK_CASE(high_collision_int)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- HashTable<int, CollidingIntTraits> table;- for (int i = 0; i < 1'000; ++i)- table.set(i);- for (int i = 0; i < 1'000; i += 3)- table.remove(i);- for (int i = 1'000; i < 1'500; ++i)- table.set(i);- }-}--BENCHMARK_CASE(high_collision_non_trivial)-{- for (int iter = 0; iter < ITERATION_COUNT; ++iter) {- HashTable<NonTrivialValue, CollidingNonTrivialTraits> table;- for (int i = 0; i < 1'000; ++i)- table.set(NonTrivialValue(i));- for (int i = 0; i < 1'000; i += 3)- table.remove(NonTrivialValue(i));- for (int i = 1'000; i < 1'500; ++i)- table.set(NonTrivialValue(i));- }-}diff --git a/Tests/AK/TestMemoryStream.cpp b/Tests/AK/TestMemoryStream.cppindex 46276d6f90a..c7f3cea2266 100644--- a/Tests/AK/TestMemoryStream.cpp+++ b/Tests/AK/TestMemoryStream.cpp@@ -217,27 +217,6 @@ TEST_CASE(fixed_memory_seeking_around)TRY_OR_FAIL(stream.read_until_filled(buffer));}-BENCHMARK_CASE(fixed_memory_tell)-{- auto stream_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(10 * KiB));- FixedMemoryStream stream { ReadonlyBytes { stream_buffer.bytes() } };-- auto expected_fixed_memory_offset = 0u;- auto ten_byte_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(1));- for (auto i = 0u; i < 4000; ++i) {- TRY_OR_FAIL(stream.read_until_filled(ten_byte_buffer));- expected_fixed_memory_offset += 1u;- EXPECT_EQ(expected_fixed_memory_offset, TRY_OR_FAIL(stream.tell()));- }-- for (auto i = 0u; i < 4000; ++i) {- auto seek_fixed_memory_offset = TRY_OR_FAIL(stream.seek(-1, SeekMode::FromCurrentPosition));- expected_fixed_memory_offset -= 1;- EXPECT_EQ(seek_fixed_memory_offset, TRY_OR_FAIL(stream.tell()));- EXPECT_EQ(expected_fixed_memory_offset, TRY_OR_FAIL(stream.tell()));- }-}-TEST_CASE(fixed_memory_truncate){auto stream_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(10 * KiB));diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cppindex 756dfb49402..2eddb1d3422 100644--- a/Tests/AK/TestString.cpp+++ b/Tests/AK/TestString.cpp@@ -842,13 +842,6 @@ TEST_CASE(to_titlecase_special_casing_i)EXPECT_EQ(result, "\u0130"sv);}-BENCHMARK_CASE(casefold)-{- for (size_t i = 0; i < 50'000; ++i) {- __test_to_casefold();- }-}-TEST_CASE(equals_ignoring_case){{@@ -1678,45 +1671,3 @@ TEST_CASE(roman_numerals)auto four_thousand = String::roman_number_from(4000, String::Case::Upper);EXPECT_EQ(four_thousand, "4000"sv);}--BENCHMARK_CASE(string_number_u16)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<u16>(12345));- }-}--BENCHMARK_CASE(string_number_u32)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<u32>(123456789));- }-}--BENCHMARK_CASE(string_number_u64)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<u64>(123456789));- }-}--BENCHMARK_CASE(string_number_i16)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<i16>(-12345));- }-}--BENCHMARK_CASE(string_number_i32)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<i32>(-123456789));- }-}--BENCHMARK_CASE(string_number_i64)-{- for (size_t i = 0; i < 10'000'000; ++i) {- (void)String::number(static_cast<i64>(-123456789));- }-}diff --git a/Tests/AK/TestStringConversions.cpp b/Tests/AK/TestStringConversions.cppindex b85fc9c21c7..b69e8996d8f 100644--- a/Tests/AK/TestStringConversions.cpp+++ b/Tests/AK/TestStringConversions.cpp@@ -434,36 +434,6 @@ TEST_CASE(parse_completely_must_be_just_floating_point)EXPECT_PARSE_COMPLETELY_TO_FAIL("1234567=890");}-#define BENCHMARK_DOUBLE_PARSING(value, iterations) \- do { \- auto data = #value##sv; \- auto true_result = value; \- for (int i = 0; i < iterations * 10'000; ++i) { \- AK::taint_for_optimizer(data); \- EXPECT_EQ(data.to_number<double>(), true_result); \- } \- } while (false)--BENCHMARK_CASE(one)-{- BENCHMARK_DOUBLE_PARSING(1, 500);-}--BENCHMARK_CASE(long_float_without_exponent)-{- BENCHMARK_DOUBLE_PARSING(1234567812345678, 400);-}--BENCHMARK_CASE(float_with_exponent)-{- BENCHMARK_DOUBLE_PARSING(1.234567e20, 400);-}--BENCHMARK_CASE(inadequate_float)-{- BENCHMARK_DOUBLE_PARSING(7.4109846876186981626485318930233205854758970392148714663837852375101326090531312779794975454245398856969484704316857659638998506553390969459816219401617281718945106978546710679176872575177347315553307795408549809608457500958111373034747658096871009590975442271004757307809711118935784838675653998783503015228055934046593739791790738723868299395818481660169122019456499931289798411362062484498678713572180352209017023903285791732520220528974020802906854021606612375549983402671300035812486479041385743401875520901590172592547146296175134159774938718574737870961645638908718119841271673056017045493004705269590165763776884908267986972573366521765567941072508764337560846003984904972149117463085539556354188641513168478436313080237596295773983001708984375001e-324, 4);-}-TEST_CASE(signed_integer){auto value = AK::parse_number<int>(StringView());@@ -821,30 +791,3 @@ TEST_CASE(decimal_conversion_without_removing_trailing_zeroes)for (auto value : to_array<float>({ 0.0f, -0.0f, 1.0f, -1.0f, 0.1f, 0.3f, 58.0f, 1e-30f, 1e30f, 0x1p-126f, bit_cast<float>(1U), NumericLimits<float>::max() }))verify(value);}--template<AK::RemoveTrailingZeroes remove_trailing_zeroes>-static void bench_float_conversion_impl()-{- static constexpr auto numbers = to_array<double>({- 123.456789,- 0.000000123456789,- 9876543210123456.0,- 1.23e-7,- 58.0,- });-- for (size_t i = 0; i < 100'000'000; i++) {- auto result = AK::convert_to_decimal_exponential_form<remove_trailing_zeroes>(numbers[i % numbers.size()]);- AK::taint_for_optimizer(result);- }-}--BENCHMARK_CASE(bench_float_conversion)-{- bench_float_conversion_impl<AK::RemoveTrailingZeroes::Yes>();-}--BENCHMARK_CASE(bench_float_conversion_without_removing_trailing_zeroes)-{- bench_float_conversion_impl<AK::RemoveTrailingZeroes::No>();-}diff --git a/Tests/AK/TestTime.cpp b/Tests/AK/TestTime.cppindex 4c87cf2a9b0..3e858d77755 100644--- a/Tests/AK/TestTime.cpp+++ b/Tests/AK/TestTime.cpp@@ -385,16 +385,6 @@ TEST_CASE(years_to_days_since_epoch_points)}}-BENCHMARK_CASE(years_to_days_since_epoch_benchmark)-{- // This benchmark takes consistently "0ms" on Linux, and "0ms" on Serenity.- for (size_t i = 0; i < 100; ++i) {- i64 actual_days = years_to_days_since_epoch(-5877640);- (void)actual_days;- EXPECT_EQ(actual_days, -2147483456);- }-}-TEST_CASE(days_since_epoch){EXPECT_EQ(days_since_epoch(1970, 1, 1), 0);diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cppindex ac6624fcfc9..38fe07c1f24 100644--- a/Tests/AK/TestVector.cpp+++ b/Tests/AK/TestVector.cpp@@ -225,43 +225,6 @@ static bool is_inline_element(auto& el, auto& vector)EXPECT(strings.capacity() >= 32u); \} \\- BENCHMARK_CASE(Vector##_append_trivial) \- { \- /* This should be super fast thanks to Vector using memmove. */ \- Vector<int> ints; \- for (int i = 0; i < 1000000; ++i) { \- ints.append(i); \- } \- for (int i = 0; i < 100; ++i) { \- Vector<int> tmp; \- tmp.extend(ints); \- EXPECT_EQ(tmp.size(), 1000000u); \- } \- } \- \- BENCHMARK_CASE(Vector##_remove_trivial) \- { \- /* This should be super fast thanks to Vector using memmove. */ \- Vector<int> ints; \- for (int i = 0; i < 10000; ++i) { \- ints.append(i); \- } \- while (!ints.is_empty()) { \- ints.remove(0); \- } \- EXPECT_EQ(ints.size(), 0u); \- } \- \- BENCHMARK_CASE(Vector##_remove_all_matching_trivial) \- { \- Vector<int> ints; \- for (int i = 0; i < 10000; ++i) { \- ints.append(i); \- } \- ints.remove_all_matching([](int value) { return value % 2 == 0; }); \- EXPECT_EQ(ints.size(), 5000u); \- } \- \TEST_CASE(Vector##_vector_remove) \{ \Vector<int> ints; \diff --git a/Tests/Compositor/BenchmarkForceDarkImageFilter.cpp b/Tests/Compositor/BenchmarkForceDarkImageFilter.cppdeleted file mode 100644index a3f4eaf771b..00000000000--- a/Tests/Compositor/BenchmarkForceDarkImageFilter.cpp+++ /dev/null@@ -1,68 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <AK/Format.h>-#include <Compositor/DisplayListPlayerSkia.h>-#include <LibCore/ElapsedTimer.h>-#include <LibTest/TestCase.h>--#include <core/SkBitmap.h>-#include <core/SkCanvas.h>-#include <core/SkColorFilter.h>-#include <core/SkImage.h>-#include <core/SkPaint.h>-#include <core/SkSamplingOptions.h>-#include <core/SkSurface.h>--// Times the shipped force-dark image filter on the CPU raster pipeline.--static constexpr int image_side = 1024;-static constexpr int draw_iterations = 20;--static sk_sp<SkImage> make_varied_test_image()-{- SkBitmap bitmap;- bitmap.allocN32Pixels(image_side, image_side);- // A deterministic spread of colors — so the filter's data-dependent branches (the sRGB transfer split, the gray- // snap) all get exercised — rather than one path being measured for the whole surface.- u32 state = 0x12345678;- for (int y = 0; y < image_side; ++y) {- for (int x = 0; x < image_side; ++x) {- state = state * 1664525 + 1013904223;- *bitmap.getAddr32(x, y) = state | 0xff000000;- }- }- bitmap.setImmutable();- return bitmap.asImage();-}--BENCHMARK_CASE(force_dark_image_filter_per_pixel)-{- auto image = make_varied_test_image();- auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(image_side, image_side));- VERIFY(surface);- auto* canvas = surface->getCanvas();-- // The unfiltered pass takes a few milliseconds, which the coarse clock's tick would swallow; the filtered pass is- // measured the same way so the two are comparable.- SkPaint unfiltered;- auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- for (int i = 0; i < draw_iterations; ++i)- canvas->drawImage(image, 0, 0, SkSamplingOptions {}, &unfiltered);- auto unfiltered_ms = timer.elapsed_milliseconds();-- SkPaint filtered;- filtered.setColorFilter(Compositor::force_dark_image_color_filter());- timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- for (int i = 0; i < draw_iterations; ++i)- canvas->drawImage(image, 0, 0, SkSamplingOptions {}, &filtered);- auto filtered_ms = timer.elapsed_milliseconds();-- auto pixels = static_cast<double>(image_side) * image_side * draw_iterations;- auto per_pixel_ns = (static_cast<double>(filtered_ms - unfiltered_ms) * 1'000'000.0) / pixels;- outln("unfiltered {} ms, filtered {} ms over {} draws of {}x{}: {:.2f} ns per filtered pixel",- unfiltered_ms, filtered_ms, draw_iterations, image_side, image_side, per_pixel_ns);-}diff --git a/Tests/Compositor/CMakeLists.txt b/Tests/Compositor/CMakeLists.txtindex d867d160140..c102efd188b 100644--- a/Tests/Compositor/CMakeLists.txt+++ b/Tests/Compositor/CMakeLists.txt@@ -9,7 +9,6 @@ set(TEST_SOURCES# These drive Skia directly, and the compositor keeps its Skia dependency private.list(APPEND TEST_SOURCES- BenchmarkForceDarkImageFilter.cppTestDisplayListImageFilters.cppTestForceDarkImageFilter.cppTestPaintingSurface.cppdiff --git a/Tests/LibCore/TestLibCoreMappedFile.cpp b/Tests/LibCore/TestLibCoreMappedFile.cppindex 0d56438f7b2..933ff0630b0 100644--- a/Tests/LibCore/TestLibCoreMappedFile.cpp+++ b/Tests/LibCore/TestLibCoreMappedFile.cpp@@ -90,25 +90,6 @@ TEST_CASE(mapped_file_seeking_around)EXPECT_EQ(buffer_contents, expected_seek_contents3);}-BENCHMARK_CASE(file_tell)-{- auto file = TRY_OR_FAIL(Core::MappedFile::map("./10kb.txt"sv, Core::MappedFile::Mode::ReadOnly));- auto expected_file_offset = 0u;- auto ten_byte_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(1));- for (auto i = 0u; i < 4000; ++i) {- TRY_OR_FAIL(file->read_until_filled(ten_byte_buffer));- expected_file_offset += 1u;- EXPECT_EQ(expected_file_offset, TRY_OR_FAIL(file->tell()));- }-- for (auto i = 0u; i < 4000; ++i) {- auto seek_file_offset = TRY_OR_FAIL(file->seek(-1, SeekMode::FromCurrentPosition));- expected_file_offset -= 1;- EXPECT_EQ(seek_file_offset, TRY_OR_FAIL(file->tell()));- EXPECT_EQ(expected_file_offset, TRY_OR_FAIL(file->tell()));- }-}-TEST_CASE(mapped_file_adopt_fd){int rc = TRY_OR_FAIL(Core::File::open("./long_lines.txt"sv, Core::File::OpenMode::Read))->leak_fd();diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cppindex ada74901fdd..af0ad2266c6 100644--- a/Tests/LibCore/TestLibCoreStream.cpp+++ b/Tests/LibCore/TestLibCoreStream.cpp@@ -107,25 +107,6 @@ TEST_CASE(file_seeking_around)EXPECT_EQ(buffer_contents, expected_seek_contents3);}-BENCHMARK_CASE(file_tell)-{- auto file = TRY_OR_FAIL(Core::File::open("./10kb.txt"sv, Core::File::OpenMode::Read));- auto expected_file_offset = 0u;- auto ten_byte_buffer = TRY_OR_FAIL(ByteBuffer::create_uninitialized(1));- for (auto i = 0u; i < 4000; ++i) {- TRY_OR_FAIL(file->read_until_filled(ten_byte_buffer));- expected_file_offset += 1u;- EXPECT_EQ(expected_file_offset, TRY_OR_FAIL(file->tell()));- }-- for (auto i = 0u; i < 4000; ++i) {- auto seek_file_offset = TRY_OR_FAIL(file->seek(-1, SeekMode::FromCurrentPosition));- expected_file_offset -= 1;- EXPECT_EQ(seek_file_offset, TRY_OR_FAIL(file->tell()));- EXPECT_EQ(expected_file_offset, TRY_OR_FAIL(file->tell()));- }-}-TEST_CASE(file_buffered_write_and_seek){auto file = TRY_OR_FAIL(Core::OutputBufferedFile::create(TRY_OR_FAIL(Core::File::open(temporary_path("file-buffered-write-test.txt"sv), Core::File::OpenMode::Truncate | Core::File::OpenMode::ReadWrite))));diff --git a/Tests/LibCrypto/TestBigInteger.cpp b/Tests/LibCrypto/TestBigInteger.cppindex f5a2e70e0cc..41c29b01110 100644--- a/Tests/LibCrypto/TestBigInteger.cpp+++ b/Tests/LibCrypto/TestBigInteger.cpp@@ -46,12 +46,6 @@ TEST_CASE(test_bigint_fib500)EXPECT_EQ(bigint_fibonacci(500).words(), result);}-BENCHMARK_CASE(bench_bigint_fib100000)-{- auto res = bigint_fibonacci(100000);- (void)res;-}-TEST_CASE(test_unsigned_bigint_clear_sensitive_data){auto value = MUST(Crypto::UnsignedBigInteger::from_base(16, "fedcba98765432100123456789abcdef"sv));@@ -470,12 +464,6 @@ TEST_CASE(test_signed_bigint_fibo500)EXPECT_EQ(result.unsigned_value().words(), expected_result);}-BENCHMARK_CASE(bench_signed_bigint_fib100000)-{- auto res = bigint_signed_fibonacci(100000);- (void)res;-}-TEST_CASE(test_signed_addition_edgecase_borrow_with_zero){Crypto::SignedBigInteger num1 { Crypto::UnsignedBigInteger { { UINT32_MAX - 3, UINT32_MAX } }, false };diff --git a/Tests/LibGC/TestMember.cpp b/Tests/LibGC/TestMember.cppindex b386481c90e..377e7ca41d3 100644--- a/Tests/LibGC/TestMember.cpp+++ b/Tests/LibGC/TestMember.cpp@@ -271,79 +271,4 @@ TEST_CASE(function_capturing_a_member_keeps_its_cell_alive)EXPECT_NE(function->function()(), 0u);}-// Walks a list of cells through compressed pointers, decoding them against the base copy or against the base exported-// from LibGC. The opaque call per cell keeps the compiler from hoisting the base out of the loop, as an ordinary DOM-// walk with calls in its body would.-static NEVER_INLINE void touch(TestCell& cell)-{- cell.value += 1;- asm volatile("" ::: "memory");-}--static GC::Root<TestCell> const& benchmark_list()-{- static GC::Root<TestCell> head = [] {- auto head = GC::make_root(test_heap().allocate<TestCell>());- GC::Ptr<TestCell> tail = head.ptr();- for (size_t i = 0; i < 100'000; ++i) {- auto cell = test_heap().allocate<TestCell>();- tail->next = cell;- tail = cell;- }- return head;- }();- return head;-}--template<typename LoadBase>-static NEVER_INLINE void walk_benchmark_list(LoadBase load_base)-{- auto* head = benchmark_list().ptr();- for (size_t round = 0; round < 1000; ++round) {- for (auto* cell = head; cell;) {- touch(*cell);- auto compressed = cell->next.compressed();- cell = compressed ? reinterpret_cast<TestCell*>(GC::decompress_nonnull(compressed, load_base())) : nullptr;- }- }-}--// The same walk, with the decode in a function of its own, so it loads the base (and its address) on every call.-template<typename LoadBase>-static NEVER_INLINE TestCell* next_cell(TestCell& cell, LoadBase load_base)-{- auto compressed = cell.next.compressed();- return compressed ? reinterpret_cast<TestCell*>(GC::decompress_nonnull(compressed, load_base())) : nullptr;-}--template<typename LoadBase>-static NEVER_INLINE void walk_benchmark_list_out_of_line(LoadBase load_base)-{- auto* head = benchmark_list().ptr();- for (size_t round = 0; round < 1000; ++round) {- for (auto* cell = head; cell; cell = next_cell(*cell, load_base))- touch(*cell);- }-}--BENCHMARK_CASE(walk_members_out_of_line_with_exported_base)-{- walk_benchmark_list_out_of_line([] { return js_heap_region_base; });-}--BENCHMARK_CASE(walk_members_out_of_line_with_base_copy)-{- walk_benchmark_list_out_of_line([] { return GC::heap_region_base(); });-}--BENCHMARK_CASE(walk_members_with_base_copy)-{- walk_benchmark_list([] { return GC::heap_region_base(); });-}--BENCHMARK_CASE(walk_members_with_exported_base)-{- walk_benchmark_list([] { return js_heap_region_base; });-}-}diff --git a/Tests/LibGfx/BenchmarkJPEGLoader.cpp b/Tests/LibGfx/BenchmarkJPEGLoader.cppdeleted file mode 100644index e97d356697c..00000000000--- a/Tests/LibGfx/BenchmarkJPEGLoader.cpp+++ /dev/null@@ -1,40 +0,0 @@-/*- * Copyright (c) 2023, Lucas Chollet <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibCore/File.h>-#include <LibGfx/ImageFormats/JPEGLoader.h>-#include <LibTest/TestCase.h>--#define TEST_INPUT(x) ("test-inputs/" x)--auto small_image = Core::File::open(TEST_INPUT("jpg/rgb24.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();-auto big_image = Core::File::open(TEST_INPUT("jpg/big_image.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();-auto rgb_image = Core::File::open(TEST_INPUT("jpg/rgb_components.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();-auto several_scans = Core::File::open(TEST_INPUT("jpg/several_scans.jpg"sv), Core::File::OpenMode::Read).release_value()->read_until_eof().release_value();--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));-}diff --git a/Tests/LibGfx/CMakeLists.txt b/Tests/LibGfx/CMakeLists.txtindex 928ddf15f4d..52507d084ed 100644--- a/Tests/LibGfx/CMakeLists.txt+++ b/Tests/LibGfx/CMakeLists.txt@@ -1,7 +1,6 @@ladybird_test_suite(LibGfx)set(TEST_SOURCES- BenchmarkJPEGLoader.cppTestColor.cppTestFont.cppTestFontCatalog.cppdiff --git a/Tests/LibMedia/TestVP9Decode.cpp b/Tests/LibMedia/TestVP9Decode.cppindex 81011428fbd..ee76920c3b2 100644--- a/Tests/LibMedia/TestVP9Decode.cpp+++ b/Tests/LibMedia/TestVP9Decode.cpp@@ -24,16 +24,6 @@ TEST_CASE(vp9_oob_blocks)decode_video("./vp9_oob_blocks.webm"sv, 240, make_decoder);}-BENCHMARK_CASE(vp9_4k)-{- decode_video("./vp9_4k.webm"sv, 2, make_decoder);-}--BENCHMARK_CASE(vp9_clamp_reference_mvs)-{- decode_video("./vp9_clamp_reference_mvs.webm"sv, 92, make_decoder);-}-TEST_CASE(input_after_the_end_of_stream_is_rejected_until_flushed){auto file = MUST(Core::File::open("./vp9_in_webm.webm"sv, Core::File::OpenMode::Read));diff --git a/Tests/LibTest/TestSuiteIsolation.cpp b/Tests/LibTest/TestSuiteIsolation.cppindex 3ed0fd258dd..fb3bee26347 100644--- a/Tests/LibTest/TestSuiteIsolation.cpp+++ b/Tests/LibTest/TestSuiteIsolation.cpp@@ -25,18 +25,18 @@ TEST_CASE(setup_and_process_state_are_isolated)TEST_CASE(suites_are_selected_by_name){Test::TestSuite suite;- auto test_case = make_ref_counted<Test::TestCase>("example"sv, "/Tests/TestExample.cpp", [] { }, false);+ auto test_case = make_ref_counted<Test::TestCase>("example"sv, "/Tests/TestExample.cpp", [] { });suite.add_case(test_case);- suite.add_case(make_ref_counted<Test::TestCase>("example"sv, "/Tests/TestExamplePeer.cpp", [] { }, false));+ suite.add_case(make_ref_counted<Test::TestCase>("example"sv, "/Tests/TestExamplePeer.cpp", [] { }));- auto matches = suite.find_cases("*", true, false, "TestExample"sv);+ auto matches = suite.find_cases("*", "TestExample"sv);EXPECT_EQ(matches.size(), 1u);if (matches.size() == 1)EXPECT_EQ(matches.first().ptr(), test_case.ptr());- EXPECT(suite.find_cases("*", true, false, "TestExample.cpp"sv).is_empty());- EXPECT(suite.find_cases("*", true, false, "/Tests/TestExample.cpp"sv).is_empty());- EXPECT(suite.find_cases("*", true, false, "TestExam"sv).is_empty());- EXPECT_EQ(suite.find_cases("TestExample::*", true, false).size(), 1u);- EXPECT(suite.find_cases("TestExample.cpp::*", true, false).is_empty());+ EXPECT(suite.find_cases("*", "TestExample.cpp"sv).is_empty());+ EXPECT(suite.find_cases("*", "/Tests/TestExample.cpp"sv).is_empty());+ EXPECT(suite.find_cases("*", "TestExam"sv).is_empty());+ EXPECT_EQ(suite.find_cases("TestExample::*").size(), 1u);+ EXPECT(suite.find_cases("TestExample.cpp::*").is_empty());}diff --git a/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp b/Tests/LibUnicode/TestUnicodeCharacterTypes.cppindex 91f4b726582..c76dc55ddc6 100644--- a/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp+++ b/Tests/LibUnicode/TestUnicodeCharacterTypes.cpp@@ -122,28 +122,6 @@ TEST_CASE(general_category)}}-BENCHMARK_CASE(general_category_performance)-{- auto general_category_cased_letter = Unicode::general_category_from_string("Cased_Letter"sv).value();-- for (size_t i = 0; i < 1'000'000; ++i) {- for (u32 code_point = 0; code_point <= 0x1f; ++code_point)- EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cased_letter));-- for (u32 code_point = 0x41; code_point <= 0x5a; ++code_point)- EXPECT(Unicode::code_point_has_general_category(code_point, general_category_cased_letter));-- for (u32 code_point = 0x61; code_point <= 0x7a; ++code_point)- EXPECT(Unicode::code_point_has_general_category(code_point, general_category_cased_letter));-- for (u32 code_point = 0xe000; code_point <= 0xe100; ++code_point)- EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cased_letter));-- for (u32 code_point = 0x101fe; code_point <= 0x1027f; ++code_point)- EXPECT(!Unicode::code_point_has_general_category(code_point, general_category_cased_letter));- }-}-TEST_CASE(property){auto property = [](StringView name) {diff --git a/Tests/LibWeb/BenchmarkDisplayListRecording.cpp b/Tests/LibWeb/BenchmarkDisplayListRecording.cppdeleted file mode 100644index 686a6919e59..00000000000--- a/Tests/LibWeb/BenchmarkDisplayListRecording.cpp+++ /dev/null@@ -1,523 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <AK/Queue.h>-#include <AK/QuickSort.h>-#include <AK/StringBuilder.h>-#include <LibCompositing/DisplayList/DisplayList.h>-#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>-#include <LibCore/AnonymousBuffer.h>-#include <LibCore/ElapsedTimer.h>-#include <LibCore/EventLoop.h>-#include <LibGfx/Palette.h>-#include <LibGfx/SystemTheme.h>-#include <LibTest/TestCase.h>-#include <LibWeb/Bindings/MainThreadVM.h>-#include <LibWeb/DOM/Document.h>-#include <LibWeb/DOM/Element.h>-#include <LibWeb/HTML/AttributeNames.h>-#include <LibWeb/HTML/LocalTraversableNavigable.h>-#include <LibWeb/HTML/PaintConfig.h>-#include <LibWeb/InvalidateDisplayList.h>-#include <LibWeb/Layout/RenderDocument.h>-#include <LibWeb/Page/Page.h>-#include <LibWeb/Painting/DocumentPaintState.h>-#include <LibWeb/Painting/PaintableTypes.h>-#include <LibWeb/Painting/PaintingRustBridge.h>-#include <LibWeb/Platform/EventLoopPlugin.h>-#include <LibWeb/Platform/FontPlugin.h>-#include <LibWebView/Utilities.h>--// Compare cold, quiet and sparse recordings of flat and nested pages. Mutations and layout are-// timed separately, and outline changes exercise fragments whose command counts grow or shrink.--namespace {--constexpr size_t cards_per_row = 40;-constexpr int card_width = 20;-constexpr int card_height = 12;-constexpr size_t timed_iterations = 200;-constexpr Web::DevicePixelSize viewport_size { Web::DevicePixels(800), Web::DevicePixels(600) };-constexpr Web::CSSPixelSize css_viewport_size { Web::CSSPixels(800), Web::CSSPixels(600) };--enum class DocumentShape {- FlatCards,- FlatCardsFew,- NestedPanels,- SharedContextCards,- TokenizedCards,-};--size_t card_count_of(DocumentShape shape)-{- // A long diff has many paint occurrences sharing one stacking context. Keep- // enough owners here to expose the cost of reconstructing the packed program.- if (shape == DocumentShape::SharedContextCards)- return 20000;- return shape == DocumentShape::FlatCardsFew ? 200 : 2000;-}--// What one timed iteration changes before recording. Each variant dirties a different set of stacking-// producers; the outline mutations also change the amount of recorded content.-enum class Mutation {- // One card's background: the dirty capture keeps its size, so nothing after it moves.- OneCardBackground,- // One card gains or loses an outline without changing layout geometry.- OneCardOutlineToggle,- // Two cards in different halves of the page: two dirty contexts under one ancestor.- TwoCardsBackground,- // The first card, with a negative z-index, gains or loses commands ahead of its siblings.- NegativeZIndexCardOutlineToggle,- // Every twentieth card: a hundred dirty contexts under one ancestor among 2000.- OneInTwentyCardsBackground,- // Every fifth card: four hundred dirty contexts under one ancestor among 2000.- OneInFiveCardsBackground,-};--// Whether the paint caches are dropped before each timed recording, so the recording starts from scratch and-// records every capture along with the bookkeeping that later warm recordings rely on.-enum class CacheState {- Warm,- Cold,-};--class BenchmarkPageClient final : public Web::PageClient {- GC_CELL(BenchmarkPageClient, Web::PageClient);- GC_DECLARE_ALLOCATOR(BenchmarkPageClient);--public:- virtual ~BenchmarkPageClient() override = default;-- void set_page(GC::Ref<Web::Page> page) { m_page = page; }-- virtual Web::PageId id() const override { return Web::PageId { 1 }; }- virtual Web::Page& page() override { return *m_page; }- virtual Web::Page const& page() const override { return *m_page; }- virtual bool is_connection_open() const override { return true; }- virtual Gfx::Palette palette() const override { return Gfx::Palette(*m_palette_impl); }- virtual Web::DevicePixelRect screen_rect() const override { return { { Web::DevicePixels(0), Web::DevicePixels(0) }, viewport_size }; }- virtual double zoom_level() const override { return 1.0; }- virtual double device_pixel_ratio() const override { return 1.0; }- virtual double device_pixels_per_css_pixel() const override { return 1.0; }- virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override { return Web::CSS::PreferredColorScheme::Light; }- virtual Web::CSS::PreferredContrast preferred_contrast() const override { return Web::CSS::PreferredContrast::NoPreference; }- virtual Web::CSS::PreferredMotion preferred_motion() const override { return Web::CSS::PreferredMotion::NoPreference; }- virtual size_t screen_count() const override { return 1; }- virtual Queue<Web::QueuedInputEvent>& input_event_queue() override { return m_input_event_queue; }- virtual void report_finished_handling_input_event(Web::PageId, u64, Web::EventResult) override { }- virtual Web::HTML::CrossProcessId allocate_cross_process_id() override { return { 1, m_next_cross_process_id++ }; }- virtual void request_frame() override { }- virtual void request_file(Web::FileRequest) override { }- virtual bool is_headless() const override { return true; }--private:- BenchmarkPageClient()- {- auto buffer = MUST(Core::AnonymousBuffer::create_with_size(sizeof(Gfx::SystemTheme)));- auto* theme = buffer.data<Gfx::SystemTheme>();- theme->color[to_underlying(Gfx::ColorRole::Window)] = Color(Color::White).value();- theme->color[to_underlying(Gfx::ColorRole::WindowText)] = Color(Color::Black).value();- theme->color[to_underlying(Gfx::ColorRole::Base)] = Color(Color::White).value();- theme->color[to_underlying(Gfx::ColorRole::BaseText)] = Color(Color::Black).value();- m_palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(move(buffer));- }-- virtual void visit_edges(JS::Cell::Visitor& visitor) override- {- Base::visit_edges(visitor);- visitor.visit(m_page);- }-- GC::Ptr<Web::Page> m_page;- RefPtr<Gfx::PaletteImpl> m_palette_impl;- Queue<Web::QueuedInputEvent> m_input_event_queue;- u64 m_next_cross_process_id { 1 };-};--GC_DEFINE_ALLOCATOR(BenchmarkPageClient);--struct LoadedPage {- AK_ALLOC_WITH_KMALLOC;-- GC::Root<BenchmarkPageClient> client;- GC::Root<Web::Page> page;- Compositing::DisplayListResourceStorage display_list_resource_storage {};- DocumentShape shape { DocumentShape::FlatCards };- size_t style_change_count { 0 };-- Web::DOM::Document& document()- {- auto document = page->local_traversable()->active_document();- VERIFY(document);- return *document;- }-};--OwnPtr<Core::EventLoop> s_event_loop;-OwnPtr<LoadedPage> s_flat_cards_page;-OwnPtr<LoadedPage> s_flat_cards_few_page;-OwnPtr<LoadedPage> s_nested_panels_page;-OwnPtr<LoadedPage> s_shared_context_cards_page;-OwnPtr<LoadedPage> s_tokenized_cards_page;--// The markup goes into the initial about:blank document's root element: navigations are driven by the browser-// process's session history, which an in-process page has no access to.-Utf16String build_document_markup(DocumentShape shape)-{- StringBuilder builder { 400'000 };- builder.append("<head><style>"sv);- builder.append("html,body{margin:0;padding:0}body{background:white;font:8px/12px monospace}"sv);- builder.append(".card{position:absolute;z-index:1;box-sizing:border-box;border:1px solid #446;background:#dde;color:#113;overflow:hidden}"sv);- if (shape == DocumentShape::SharedContextCards)- builder.append(".card{z-index:auto}"sv);- builder.append(".token:nth-child(2n){color:#c40}.token:nth-child(2n+1){color:#048}"sv);- builder.append(".panel{position:relative;z-index:0;width:800px;height:600px}"sv);- builder.append("#negative{position:absolute;z-index:-1;left:0;top:0;width:800px;height:600px;background:#eef}"sv);- builder.append("</style></head><body>"sv);- size_t open_panels = 0;- if (shape == DocumentShape::NestedPanels) {- for (; open_panels < 3; ++open_panels)- builder.append("<div class=panel>"sv);- }- builder.append("<div id=negative></div>"sv);- for (size_t i = 0; i < card_count_of(shape); ++i) {- auto columns = shape == DocumentShape::TokenizedCards ? 4 : cards_per_row;- auto width = shape == DocumentShape::TokenizedCards ? 200 : card_width;- auto left = static_cast<int>(i % columns) * width;- auto top = static_cast<int>(i / columns) * card_height;- builder.appendff("<div class=card id=card-{} style=\"left:{}px;top:{}px;width:{}px;height:{}px\">", i, left, top, width, card_height);- if (shape == DocumentShape::TokenizedCards) {- for (auto token : { "auto"sv, " value"sv, " ="sv, " foo"sv, "("sv, "42"sv, ")"sv, ";"sv })- builder.appendff("<span class=token>{}</span>", token);- } else {- builder.appendff("{}", i % 100);- }- builder.append("</div>"sv);- }- for (; open_panels > 0; --open_panels)- builder.append("</div>"sv);- builder.append("</body>"sv);- return Utf16String::from_utf8_without_validation(builder.string_view());-}--void initialize_web_platform()-{- s_event_loop = make<Core::EventLoop>();-- WebView::platform_init();- Web::Platform::EventLoopPlugin::install(*new Web::Platform::EventLoopPlugin);-- // System fonts, like the other in-process page tests: the test binaries have no resource directory to load- // the bundled fonts from.- Web::Platform::FontPlugin::install(*new Web::Platform::FontPlugin(false));-- Web::Bindings::initialize_agent(Web::HTML::AgentType::SimilarOriginWindow);-}--Web::HTML::PaintConfig benchmark_paint_config()-{- return Web::HTML::PaintConfig {- .paint_overlay = false,- .canvas_fill_rect = Gfx::IntRect { 0, 0, viewport_size.width().value(), viewport_size.height().value() },- };-}--RefPtr<Compositing::DisplayList> record_display_list(LoadedPage& loaded_page)-{- auto& document = loaded_page.document();- document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);- Web::Layout::ForcedReadScope read { document };- return document.record_display_list(read, benchmark_paint_config(), loaded_page.display_list_resource_storage, Web::Painting::PaintCommandCacheMode::ReadWrite);-}--OwnPtr<LoadedPage> load_page(DocumentShape shape)-{- auto& vm = Web::Bindings::main_thread_vm();- auto client = vm.heap().allocate<BenchmarkPageClient>();- auto page = Web::Page::create(client);- client->set_page(page);-- page->set_is_scripting_enabled(false);- page->set_window_size(viewport_size);- auto traversable = Web::HTML::LocalTraversableNavigable::create_a_new_top_level_traversable(page, nullptr, {});- page->set_top_level_traversable(traversable);- traversable->set_viewport_size(css_viewport_size, Web::InvalidateDisplayList::PaintCommandsAndHitTestList);-- auto document = traversable->active_document();- VERIFY(document);- document->set_quirks_mode(Web::DOM::QuirksMode::No);- auto markup = build_document_markup(shape);- MUST(document->document_element()->set_inner_html(markup));-- auto loaded_page = make<LoadedPage>(GC::make_root(client), GC::make_root(page));- loaded_page->shape = shape;- // Populate the per-paintable paint command caches before timing the warm path.- VERIFY(record_display_list(*loaded_page));- VERIFY(record_display_list(*loaded_page));- return loaded_page;-}--LoadedPage& page_for(DocumentShape shape)-{- auto& slot = [&]() -> OwnPtr<LoadedPage>& {- switch (shape) {- case DocumentShape::FlatCards:- return s_flat_cards_page;- case DocumentShape::FlatCardsFew:- return s_flat_cards_few_page;- case DocumentShape::NestedPanels:- return s_nested_panels_page;- case DocumentShape::SharedContextCards:- return s_shared_context_cards_page;- case DocumentShape::TokenizedCards:- return s_tokenized_cards_page;- }- VERIFY_NOT_REACHED();- }();- if (!slot)- slot = load_page(shape);- return *slot;-}--void set_card_style(LoadedPage& loaded_page, size_t card_index, StringView background, bool framed)-{- auto card = loaded_page.document().get_element_by_id(Utf16String::formatted("card-{}", card_index));- VERIFY(card);- auto left = static_cast<int>(card_index % cards_per_row) * card_width;- auto top = static_cast<int>(card_index / cards_per_row) * card_height;- card->set_attribute_value(Web::HTML::AttributeNames::style, Utf16String::formatted("left:{}px;top:{}px;width:{}px;height:{}px;background:{}{}", left, top, card_width, card_height, background, framed ? ";outline:2px solid #800"sv : ""sv));-}--void apply_mutation(LoadedPage& loaded_page, Mutation mutation)-{- auto count = card_count_of(loaded_page.shape);- auto alternate = loaded_page.style_change_count % 2 == 0;- ++loaded_page.style_change_count;- switch (mutation) {- case Mutation::OneCardBackground:- set_card_style(loaded_page, count / 2, alternate ? "#fdd"sv : "#dfd"sv, false);- break;- case Mutation::OneCardOutlineToggle:- set_card_style(loaded_page, count / 2, "#dde"sv, alternate);- break;- case Mutation::TwoCardsBackground:- set_card_style(loaded_page, count / 4, alternate ? "#fdd"sv : "#dfd"sv, false);- set_card_style(loaded_page, count * 3 / 4, alternate ? "#dfd"sv : "#fdd"sv, false);- break;- case Mutation::NegativeZIndexCardOutlineToggle: {- auto negative = loaded_page.document().get_element_by_id("negative"_utf16);- VERIFY(negative);- negative->set_attribute_value(Web::HTML::AttributeNames::style, alternate ? "outline:2px solid #800"_utf16 : "outline:none"_utf16);- break;- }- case Mutation::OneInTwentyCardsBackground:- for (size_t index = 10; index < count; index += 20)- set_card_style(loaded_page, index, alternate ? "#fdd"sv : "#dfd"sv, false);- break;- case Mutation::OneInFiveCardsBackground:- for (size_t index = 2; index < count; index += 5)- set_card_style(loaded_page, index, alternate ? "#fdd"sv : "#dfd"sv, false);- break;- }-}--struct Samples {- Vector<u64> microseconds;-- void report(StringView label)- {- quick_sort(microseconds);- u64 total = 0;- for (auto sample : microseconds)- total += sample;- outln("{}: median {} µs, min {} µs, mean {} µs over {} recordings", label, microseconds[microseconds.size() / 2], microseconds.first(), total / microseconds.size(), microseconds.size());- }-};--// The style change and its layout update are timed separately from the recording, so the invalidation and-// relayout cost of each mutation is visible next to the recording it triggers.-void time_document_recordings(DocumentShape shape, StringView label, Optional<Mutation> mutation, CacheState cache_state = CacheState::Warm)-{- auto& loaded_page = page_for(shape);- auto& document = loaded_page.document();- Samples layout_samples;- Samples samples;- size_t recorded_byte_count = 0;- for (size_t i = 0; i < timed_iterations; ++i) {- auto layout_timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- if (mutation.has_value())- apply_mutation(loaded_page, *mutation);- document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);- layout_samples.microseconds.append(layout_timer.elapsed_time().to_microseconds());- // The fresh visual context tree is built before the timer starts, so only the recording is timed.- if (cache_state == CacheState::Cold) {- document.schedule_full_accumulated_visual_context_rebuild(Web::Layout::RustFFI::VisualContextUpdateScope::FreshTree);- (void)document.visual_context_tree();- }- Web::Layout::ForcedReadScope read { document };- auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- auto display_list = document.record_display_list(read, benchmark_paint_config(), loaded_page.display_list_resource_storage, Web::Painting::PaintCommandCacheMode::ReadWrite);- samples.microseconds.append(timer.elapsed_time().to_microseconds());- VERIFY(display_list);- recorded_byte_count = display_list->tape_size();- }- outln("{} bytes of display list commands", recorded_byte_count);- layout_samples.report(" mutation and layout"sv);- samples.report(label);-}--// The Rust recording and publication alone, without the document-level bookkeeping that follows a recording-// (collecting referenced resources and rebuilding the hit-test display list).-void time_rust_recordings(DocumentShape shape, StringView label)-{- auto& loaded_page = page_for(shape);- auto& document = loaded_page.document();- Samples samples;- for (size_t i = 0; i < timed_iterations; ++i) {- apply_mutation(loaded_page, Mutation::OneCardBackground);- document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);- auto visual_context_tree = document.paint_state().visual_context_tree(document);- Web::Painting::InspectorOverlayInputs overlay_inputs;- Web::Layout::ForcedReadScope read { document };- auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- auto recording = Web::Painting::start_rust_display_list_recording(read, document, visual_context_tree, {}, Web::Painting::PaintCommandCacheMode::ReadWrite, benchmark_paint_config(), overlay_inputs);- VERIFY(recording.has_value());- auto display_list = Web::Painting::finish_rust_display_list_recording(read, document, *recording, loaded_page.display_list_resource_storage);- samples.microseconds.append(timer.elapsed_time().to_microseconds());- VERIFY(display_list);- }- samples.report(label);-}--void time_removal_recordings(DocumentShape shape, StringView label)-{- auto& loaded_page = page_for(shape);- auto& document = loaded_page.document();- auto card = GC::make_root(*document.get_element_by_id("card-1000"_utf16));- auto parent = GC::make_root(*card->parent());- Samples layout_samples;- Samples recording_samples;- for (size_t iteration = 0; iteration < timed_iterations; ++iteration) {- auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- if (card->parent())- card->remove();- else- MUST(parent->append_child(*card));- document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);- layout_samples.microseconds.append(timer.elapsed_time().to_microseconds());- Web::Layout::ForcedReadScope read { document };- timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- VERIFY(document.record_display_list(read, benchmark_paint_config(), loaded_page.display_list_resource_storage, Web::Painting::PaintCommandCacheMode::ReadWrite));- recording_samples.microseconds.append(timer.elapsed_time().to_microseconds());- }- layout_samples.report(" removal/attachment and layout"sv);- recording_samples.report(label);-}--}--TEST_SETUP-{- initialize_web_platform();-}--BENCHMARK_CASE(document_record_after_one_card_style_change_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, one dirty"sv, Mutation::OneCardBackground);-}--BENCHMARK_CASE(document_record_after_one_card_style_change_among_2000_nested)-{- time_document_recordings(DocumentShape::NestedPanels, "document recording, nested panels, one dirty"sv, Mutation::OneCardBackground);-}--BENCHMARK_CASE(document_record_after_one_card_style_change_among_200_flat)-{- time_document_recordings(DocumentShape::FlatCardsFew, "document recording, 200 flat cards, one dirty"sv, Mutation::OneCardBackground);-}--BENCHMARK_CASE(document_record_after_one_card_grows_or_shrinks_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, one dirty changing size"sv, Mutation::OneCardOutlineToggle);-}--BENCHMARK_CASE(document_record_after_two_cards_change_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, two dirty"sv, Mutation::TwoCardsBackground);-}--BENCHMARK_CASE(document_record_after_negative_z_index_card_changes_size_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, negative z-index dirty changing size"sv, Mutation::NegativeZIndexCardOutlineToggle);-}--BENCHMARK_CASE(document_record_after_one_in_twenty_cards_change_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, 100 dirty"sv, Mutation::OneInTwentyCardsBackground);-}--BENCHMARK_CASE(document_record_after_one_in_five_cards_change_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, 400 dirty"sv, Mutation::OneInFiveCardsBackground);-}--BENCHMARK_CASE(document_record_cold_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, cold"sv, Mutation::OneCardBackground, CacheState::Cold);-}--BENCHMARK_CASE(document_record_cold_among_2000_nested)-{- time_document_recordings(DocumentShape::NestedPanels, "document recording, nested panels, cold"sv, Mutation::OneCardBackground, CacheState::Cold);-}--BENCHMARK_CASE(rust_record_after_one_card_style_change_among_2000_flat)-{- time_rust_recordings(DocumentShape::FlatCards, "rust recording, flat cards, one dirty"sv);-}--BENCHMARK_CASE(rust_record_after_one_card_style_change_among_2000_nested)-{- time_rust_recordings(DocumentShape::NestedPanels, "rust recording, nested panels, one dirty"sv);-}--BENCHMARK_CASE(document_record_quiet_frame_among_2000_flat)-{- time_document_recordings(DocumentShape::FlatCards, "document recording, flat cards, quiet"sv, {});-}--BENCHMARK_CASE(document_record_after_removal_in_shared_stacking_context)-{- time_removal_recordings(DocumentShape::SharedContextCards, "document recording, shared context, one card removed/attached"sv);-}--BENCHMARK_CASE(document_record_after_removal_among_tokenized_cards)-{- time_removal_recordings(DocumentShape::TokenizedCards, "document recording, tokenized cards, one card removed/attached"sv);-}--BENCHMARK_CASE(document_record_after_viewport_scroll_and_one_card_change)-{- auto loaded_page = load_page(DocumentShape::FlatCards);- auto& document = loaded_page->document();- document.document_element()->set_attribute("style"_fly_string, "height:2400px"_utf16);- VERIFY(record_display_list(*loaded_page));- Samples layout_samples;- Samples recording_samples;- for (size_t iteration = 0; iteration < timed_iterations; ++iteration) {- auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- loaded_page->page->local_traversable()->perform_scroll_of_viewport_scrolling_box({ 0, iteration % 2 ? 200 : 300 });- apply_mutation(*loaded_page, Mutation::OneCardBackground);- document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);- layout_samples.microseconds.append(timer.elapsed_time().to_microseconds());- Web::Layout::ForcedReadScope read { document };- timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);- VERIFY(document.record_display_list(read, benchmark_paint_config(), loaded_page->display_list_resource_storage, Web::Painting::PaintCommandCacheMode::ReadWrite));- recording_samples.microseconds.append(timer.elapsed_time().to_microseconds());- }- layout_samples.report(" scrolling, mutation and layout"sv);- recording_samples.report("document recording, viewport scroll and one changed card"sv);-}diff --git a/Tests/LibWeb/CMakeLists.txt b/Tests/LibWeb/CMakeLists.txtindex 2a7cb5f39f3..4a0e5e9f65b 100644--- a/Tests/LibWeb/CMakeLists.txt+++ b/Tests/LibWeb/CMakeLists.txt@@ -11,7 +11,6 @@ endif()ladybird_test_suite(LibWeb)set(TEST_SOURCES- BenchmarkDisplayListRecording.cppTestBlobBytes.cppTestContentBlocker.cppTestCSSDecodeBytes.cppdiff --git a/Tests/LibWeb/TestCSSIDSpeed.cpp b/Tests/LibWeb/TestCSSIDSpeed.cppindex 5b2b47a1d26..a5a1ccd551b 100644--- a/Tests/LibWeb/TestCSSIDSpeed.cpp+++ b/Tests/LibWeb/TestCSSIDSpeed.cpp@@ -29,51 +29,3 @@ TEST_CASE(basic)EXPECT(!Web::CSS::property_id_from_string("not-a-property"sv).has_value());EXPECT(!Web::CSS::property_id_from_string(u"not-a-property"sv).has_value());}--BENCHMARK_CASE(keyword_from_string)-{- for (size_t i = 0; i < 10'000'000; ++i) {- EXPECT_EQ(Web::CSS::keyword_from_string("inline"sv).value(), Web::CSS::Keyword::Inline);- }-}--BENCHMARK_CASE(keyword_from_utf16_string)-{- for (size_t i = 0; i < 10'000'000; ++i) {- EXPECT_EQ(Web::CSS::keyword_from_string(u"inline"sv).value(), Web::CSS::Keyword::Inline);- }-}--BENCHMARK_CASE(all_properties_from_string)-{- Vector<String> names;- for (auto i = to_underlying(Web::CSS::first_property_id); i <= to_underlying(Web::CSS::last_property_id); ++i)- names.append(MUST(Web::CSS::string_from_property_id(static_cast<Web::CSS::PropertyID>(i)).view().to_utf8()));-- for (size_t iteration = 0; iteration < 20'000; ++iteration) {- for (auto i = to_underlying(Web::CSS::first_property_id); i <= to_underlying(Web::CSS::last_property_id); ++i) {- auto property_id = static_cast<Web::CSS::PropertyID>(i);- EXPECT_EQ(Web::CSS::property_id_from_string(names[i - to_underlying(Web::CSS::first_property_id)]).value(), property_id);- }- }-}--BENCHMARK_CASE(all_properties_from_utf16_string)-{- Vector<Vector<char16_t>> names;- for (auto i = to_underlying(Web::CSS::first_property_id); i <= to_underlying(Web::CSS::last_property_id); ++i) {- Vector<char16_t> name;- auto property_name = Web::CSS::string_from_property_id(static_cast<Web::CSS::PropertyID>(i)).view();- for (size_t j = 0; j < property_name.length_in_code_units(); ++j)- name.append(property_name.code_unit_at(j));- names.append(move(name));- }-- for (size_t iteration = 0; iteration < 20'000; ++iteration) {- for (auto i = to_underlying(Web::CSS::first_property_id); i <= to_underlying(Web::CSS::last_property_id); ++i) {- auto property_id = static_cast<Web::CSS::PropertyID>(i);- auto const& name = names[i - to_underlying(Web::CSS::first_property_id)];- EXPECT_EQ(Web::CSS::property_id_from_string(Utf16View { name.data(), name.size() }).value(), property_id);- }- }-}