OLD | NEW |
1 library dom_traverse_html; | 1 library dom_traverse_html; |
2 import 'dart:html'; | 2 import 'dart:html'; |
3 import '../common/common.dart'; | 3 import '../common/common.dart'; |
4 import 'dart:math' as Math; | 4 import 'dart:math' as Math; |
5 part 'Common.dart'; | 5 part 'Common.dart'; |
6 part 'RunnerSuite.dart'; | 6 part 'RunnerSuite.dart'; |
7 | 7 |
8 void main() { | 8 void main() { |
9 final int num = 40; | 9 final int num = 40; |
10 | 10 |
11 // Try to force real results. | 11 // Try to force real results. |
12 var ret; | 12 var ret; |
13 | 13 |
14 String html = document.body.innerHTML; | 14 String html = document.body.innerHtml; |
15 | 15 |
16 new Suite(window, 'dom-traverse') | 16 new Suite(window, 'dom-traverse') |
17 .prep(() { | 17 .prep(() { |
18 html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { | 18 html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { |
19 final group = match.group(1); | 19 final group = match.group(1); |
20 return 'id="test${group}${num}"'; | 20 return 'id="test${group}${num}"'; |
21 }); | 21 }); |
22 html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { | 22 html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { |
23 return 'name="test${num}"'; | 23 return 'name="test${num}"'; |
24 }); | 24 }); |
25 html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { | 25 html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { |
26 return 'class="foo test${num} bar"'; | 26 return 'class="foo test${num} bar"'; |
27 }); | 27 }); |
28 | 28 |
29 final div = new Element.tag('div'); | 29 final div = new Element.tag('div'); |
30 div.innerHTML = html; | 30 div.innerHtml = html; |
31 document.body.nodes.add(div); | 31 document.body.nodes.add(div); |
32 }) | 32 }) |
33 .test('firstChild', () { | 33 .test('firstChild', () { |
34 final nodes = document.body.nodes; | 34 final nodes = document.body.nodes; |
35 final nl = nodes.length; | 35 final nl = nodes.length; |
36 | 36 |
37 for (int i = 0; i < num; i++) { | 37 for (int i = 0; i < num; i++) { |
38 for (int j = 0; j < nl; j++) { | 38 for (int j = 0; j < nl; j++) { |
39 Node cur = nodes[j]; | 39 Node cur = nodes[j]; |
40 while (cur != null) { | 40 while (cur != null) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 .test('childNodes', () { | 79 .test('childNodes', () { |
80 for (int i = 0; i < num; i++) { | 80 for (int i = 0; i < num; i++) { |
81 final nodes = document.body.nodes; | 81 final nodes = document.body.nodes; |
82 for (int j = 0; j < nodes.length; j++) { | 82 for (int j = 0; j < nodes.length; j++) { |
83 ret = nodes[j]; | 83 ret = nodes[j]; |
84 } | 84 } |
85 } | 85 } |
86 }) | 86 }) |
87 .end(); | 87 .end(); |
88 } | 88 } |
OLD | NEW |