OLD | NEW |
| (Empty) |
1 library dromaeo; | |
2 import 'dart:async'; | |
3 import 'dart:html'; | |
4 import "dart:convert"; | |
5 import '../common/common.dart'; | |
6 import 'dart:math' as Math; | |
7 part 'Common.dart'; | |
8 part 'RunnerSuite.dart'; | |
9 | |
10 | |
11 void main() { | |
12 final int num = 40; | |
13 | |
14 // Try to force real results. | |
15 var ret; | |
16 | |
17 String html = document.body.innerHtml; | |
18 | |
19 new Suite(window, 'dom-traverse') | |
20 .prep(() { | |
21 html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { | |
22 final group = match.group(1); | |
23 return 'id="test${group}${num}"'; | |
24 }); | |
25 html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { | |
26 return 'name="test${num}"'; | |
27 }); | |
28 html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { | |
29 return 'class="foo test${num} bar"'; | |
30 }); | |
31 | |
32 final div = new Element.tag('div'); | |
33 div.innerHtml = html; | |
34 document.body.append(div); | |
35 }) | |
36 .test('firstChild', () { | |
37 final nodes = document.body.childNodes; | |
38 final nl = nodes.length; | |
39 | |
40 for (int i = 0; i < num; i++) { | |
41 for (int j = 0; j < nl; j++) { | |
42 Node cur = nodes[j]; | |
43 while (cur != null) { | |
44 cur = cur.firstChild; | |
45 } | |
46 ret = cur; | |
47 } | |
48 } | |
49 }) | |
50 .test('lastChild', () { | |
51 final nodes = document.body.childNodes; | |
52 final nl = nodes.length; | |
53 | |
54 for (int i = 0; i < num; i++) { | |
55 for (int j = 0; j < nl; j++) { | |
56 Node cur = nodes[j]; | |
57 while (cur != null) { | |
58 cur = cur.lastChild; | |
59 } | |
60 ret = cur; | |
61 } | |
62 } | |
63 }) | |
64 .test('nextSibling', () { | |
65 for (int i = 0; i < num * 2; i++) { | |
66 Node cur = document.body.firstChild; | |
67 while (cur != null) { | |
68 cur = cur.nextNode; | |
69 } | |
70 ret = cur; | |
71 } | |
72 }) | |
73 .test('previousSibling', () { | |
74 for (int i = 0; i < num * 2; i++) { | |
75 Node cur = document.body.lastChild; | |
76 while (cur != null) { | |
77 cur = cur.previousNode; | |
78 } | |
79 ret = cur; | |
80 } | |
81 }) | |
82 .test('childNodes', () { | |
83 for (int i = 0; i < num; i++) { | |
84 final nodes = document.body.childNodes; | |
85 for (int j = 0; j < nodes.length; j++) { | |
86 ret = nodes[j]; | |
87 } | |
88 } | |
89 }) | |
90 .end(); | |
91 } | |
OLD | NEW |