Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: PerformanceTests/Layout/resources/character_fallback_test.js

Issue 360363002: Adding a performance test for font fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@benchmarkBefore
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PerformanceTests/Layout/resources/character_fallback_chars.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PerformanceTests/Layout/resources/character_fallback_test.js
diff --git a/PerformanceTests/Layout/resources/character_fallback_test.js b/PerformanceTests/Layout/resources/character_fallback_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..d2fb2ad4e9053b73dc38182e6f6bc4bc78b627a0
--- /dev/null
+++ b/PerformanceTests/Layout/resources/character_fallback_test.js
@@ -0,0 +1,34 @@
+// Perf Tests run a maximum of 20 times,
+// make sure we have an equal amount of characters
+// for each run.
+var selectionSize = fallbackChars.length / 21;
+var target;
+
+function test() {
+ var charSelection = "";
+ for(var i=0; i < selectionSize; i++) {
+ var selectedCharIndex = Math.floor(Math.random() * fallbackChars.length);
+ if(!fallbackChars[selectedCharIndex])
+ continue;
+ charSelection += fallbackChars[selectedCharIndex];
+ fallbackChars.splice(selectedCharIndex, 1);
+ }
+ if (charSelection.length)
+ replaceTextAndWaitForLayout(charSelection);
+}
+
+function replaceTextAndWaitForLayout(charSelection) {
+ while (target.firstChild)
+ target.removeChild(target.firstChild);
+ target.appendChild(document.createTextNode(charSelection));
+ target.offsetHeight;
+}
+
+function cleanup() {
+ replaceTextAndWaitForLayout("");
+}
+
+function startTest() {
+ target = document.querySelector("#target");
+ PerfTestRunner.measureTime({ run: test, done: cleanup, description: "Per-character font fallback" });
+}
« no previous file with comments | « PerformanceTests/Layout/resources/character_fallback_chars.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698