Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / PerformanceTests / Layout / chapter-reflow-once-random.html
blob6177470ea400c76c7a088250d4de3a01fcfb150f
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Chapter reflow performance test: random text</title>
5 <script src="../resources/runner.js"></script>
6 </head>
7 <body>
8 <pre id="log"></pre>
9 <div id="target" style="width: 300px; display: none;">
11 </div>
12 <script>
13 var RandomTextGenerator = function() {
14 this.letters = [
15 String.fromCharCode(RandomTextGenerator.firstCharCode),
16 String.fromCharCode(RandomTextGenerator.firstCharCode),
17 String.fromCharCode(RandomTextGenerator.firstCharCode),
18 String.fromCharCode(RandomTextGenerator.firstCharCode),
19 String.fromCharCode(RandomTextGenerator.firstCharCode),
20 String.fromCharCode(RandomTextGenerator.firstCharCode),
21 String.fromCharCode(RandomTextGenerator.firstCharCode),
22 String.fromCharCode(RandomTextGenerator.firstCharCode),
23 String.fromCharCode(RandomTextGenerator.firstCharCode),
24 String.fromCharCode(RandomTextGenerator.firstCharCode)
28 RandomTextGenerator.firstCharCode = 65; // 'A'
30 RandomTextGenerator.lastCharCode = 123; // 'z'
32 RandomTextGenerator.prototype.advance = function(index) {
33 var charCode = this.letters[index].charCodeAt(0);
34 var newCharCode = charCode + 1;
35 if (newCharCode > RandomTextGenerator.lastCharCode)
36 newCharCode = RandomTextGenerator.firstCharCode;
37 this.letters[index] = String.fromCharCode(newCharCode);
38 return charCode;
41 RandomTextGenerator.prototype.generate = function() {
42 var result = this.letters.join("");
44 var index = 0;
45 while (1) {
46 var charCode = this.advance(index);
47 if (charCode != RandomTextGenerator.lastCharCode)
48 break;
49 ++index;
52 return result;
55 var target = document.getElementById("target");
56 var style = target.style;
57 var randomTextGenerator = new RandomTextGenerator;
59 function test() {
60 var target = document.getElementById("target");
61 var style = target.style;
63 var innerHTML = "<p>";
64 for (var i = 0; i < 5000; ++i)
65 innerHTML += randomTextGenerator.generate() + " ";
66 innerHTML += "</p>";
67 target.innerHTML = innerHTML;
69 style.display = "block";
70 style.width = "280px";
71 PerfTestRunner.forceLayoutOrFullFrame();
72 style.display = "none";
75 PerfTestRunner.measureRunsPerSecond({
76 description: "Measures performance of 3 layouts (using 2 different font-sizes) on a page containing random text.",
77 run: test
78 });
79 </script>
80 </body>
81 </html>