summaryrefslogtreecommitdiff
path: root/Tests/LibWeb/TestCSSIDSpeed.cpp
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2023-01-09 22:31:20 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2023-01-14 15:43:27 -0700
commitb3d2fdceb165790c0595f02ad1e1395b03794bcd (patch)
treef543533054fd0ca5aa44eeaadba46a33ce4905c1 /Tests/LibWeb/TestCSSIDSpeed.cpp
parent0687a75eaaf7b639133283b19711d80222647b1b (diff)
downloadserenity-b3d2fdceb165790c0595f02ad1e1395b03794bcd.zip
LibWeb+Tests: Demonstrate slowness of CSS::value_id_from_string
Diffstat (limited to 'Tests/LibWeb/TestCSSIDSpeed.cpp')
-rw-r--r--Tests/LibWeb/TestCSSIDSpeed.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/LibWeb/TestCSSIDSpeed.cpp b/Tests/LibWeb/TestCSSIDSpeed.cpp
new file mode 100644
index 0000000000..e42e7da8f7
--- /dev/null
+++ b/Tests/LibWeb/TestCSSIDSpeed.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2023, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+
+#include <LibWeb/CSS/ValueID.h>
+
+TEST_CASE(basic)
+{
+ EXPECT_EQ(Web::CSS::value_id_from_string("italic"sv), Web::CSS::ValueID::Italic);
+ EXPECT_EQ(Web::CSS::value_id_from_string("inline"sv), Web::CSS::ValueID::Inline);
+ EXPECT_EQ(Web::CSS::value_id_from_string("small"sv), Web::CSS::ValueID::Small);
+ EXPECT_EQ(Web::CSS::value_id_from_string("smalL"sv), Web::CSS::ValueID::Small);
+ EXPECT_EQ(Web::CSS::value_id_from_string("SMALL"sv), Web::CSS::ValueID::Small);
+ EXPECT_EQ(Web::CSS::value_id_from_string("Small"sv), Web::CSS::ValueID::Small);
+ EXPECT_EQ(Web::CSS::value_id_from_string("smALl"sv), Web::CSS::ValueID::Small);
+}
+
+BENCHMARK_CASE(value_id_from_string)
+{
+ for (size_t i = 0; i < 10'000'000; ++i) {
+ EXPECT_EQ(Web::CSS::value_id_from_string("inline"sv), Web::CSS::ValueID::Inline);
+ }
+}