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