Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <!-- | |
| 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 4 for details. All rights reserved. Use of this source code is governed by a | |
| 5 BSD-style license that can be found in the LICENSE file. | |
| 6 --> | |
| 7 <html lang="en"> | |
| 8 <head> | |
| 9 <!-- | |
| 10 This performance test mutates a list of 100 elements used in a single loop. | |
|
Jennifer Messerly
2013/01/07 21:07:46
what's perf like for N=1000?
Siggi Cherem (dart-lang)
2013/01/08 02:26:18
It's about 10x slower.
| |
| 11 --> | |
| 12 <meta charset="utf-8"> | |
| 13 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| 14 <script type="application/javascript" src="testing.js"></script> | |
| 15 <script type="application/javascript" src="start_dart.js"></script> | |
| 16 </head> | |
| 17 <body> | |
| 18 <template iterate="x in list"> | |
| 19 <span>{{x}}</span> | |
| 20 </template> | |
| 21 <script type="application/dart"> | |
| 22 import 'dart:html'; | |
| 23 import 'package:web_ui/web_ui.dart'; | |
| 24 import 'package:unittest/unittest.dart'; | |
| 25 import 'perf_common.dart'; | |
| 26 | |
| 27 main() { | |
| 28 useShadowDom = false; | |
| 29 window.setTimeout(() { | |
| 30 var bench = new LoopBenchmark(); | |
| 31 perfDone(bench.measure()); | |
| 32 }, 0); | |
| 33 } | |
| 34 | |
| 35 const DEFAULT_LIST = const [ | |
| 36 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 37 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 38 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 39 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 40 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 41 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 42 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 43 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 44 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 45 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, | |
| 46 ]; | |
| 47 | |
| 48 List list = []; | |
| 49 | |
| 50 class LoopBenchmark extends BenchmarkBase { | |
| 51 LoopBenchmark() : super('loop-1-100'); | |
| 52 int pos = 0; | |
| 53 setup() { | |
| 54 list.clear(); | |
| 55 list.addAll(DEFAULT_LIST); | |
| 56 pos = 0; | |
| 57 } | |
| 58 | |
| 59 run() { | |
| 60 list[pos] += 1; | |
| 61 pos = (pos + 1) % DEFAULT_LIST.length; | |
| 62 dispatch(); | |
| 63 } | |
| 64 } | |
| 65 </script> | |
| 66 </body> | |
| 67 </html> | |
| OLD | NEW |