Introduce blink/perf_tests/paint/select-all-words.html
This patch introduces a performance test file "select-all-words.html" for
measuring painting selection.
See https://bit.ly/2SyNQS1 for profiling sample comparing legacy layout and
LayoutNG.
As of February 7, 2019, LayoutNG is two times slower than legacy layout.
Change-Id: I8c5fe8418715b7d0078f6f1186c4191a1fb7d850
Reviewed-on: https://chromium-review.googlesource.com/c/1457701
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629909}
diff --git a/third_party/blink/perf_tests/paint/select-all-words.html b/third_party/blink/perf_tests/paint/select-all-words.html
new file mode 100644
index 0000000..b746f42b
--- /dev/null
+++ b/third_party/blink/perf_tests/paint/select-all-words.html
@@ -0,0 +1,60 @@
+<!doctype html>
+<body>
+<script src="../resources/runner.js"></script>
+<script src="../layout/resources/line-layout-perf-test.js"></script>
+<div id="container"></div>
+<script>
+const kNumberOfWords = 10000 * 30;
+const kCount = 10;
+const container = document.getElementById('container');
+const selection = window.getSelection();
+
+container.textContent = (() => {
+ const words = [];
+ for (let i = 0; i < kNumberOfWords; ++i)
+ words.push(TextGenerator.createWord(i % 12 + 3));
+ return words.join(' ');
+})();
+
+let isDone = false;
+let startTime = 0;
+let counter = 0;
+
+function runTest() {
+ if (startTime !== 0 && counter % kCount === 0) {
+ PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
+ PerfTestRunner.addRunTestEndMarker(); // For tracing metrics
+ }
+ if (isDone)
+ return;
+ window.requestAnimationFrame(() => {
+ if (counter % kCount === 0) {
+ PerfTestRunner.addRunTestStartMarker();
+ startTime = PerfTestRunner.now(); // For tracing metrics
+ }
+ selection.collapse(container, 0);
+ if (counter % 2 === 1)
+ selection.extend(container, 1);
+ ++counter;
+ runTest();
+ });
+}
+
+
+PerfTestRunner.startMeasureValuesAsync({
+ unit: 'ms',
+ run: function() {
+ runTest();
+ },
+ done: function() {
+ container.textContent = '';
+ isDone = true;
+ },
+ iterationCount: 10,
+ tracingCategories: 'blink',
+ traceEventsToMeasure: [
+ 'LocalFrameView::RunPrePaintLifecyclePhase',
+ 'LocalFrameView::RunPaintLifecyclePhase'
+ ],
+});
+</script>