Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: third_party/pkg/angular/perf/loop_perf.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/perf/loop_perf.dart
diff --git a/third_party/pkg/angular/perf/loop_perf.dart b/third_party/pkg/angular/perf/loop_perf.dart
new file mode 100644
index 0000000000000000000000000000000000000000..819daf45583af725cc4f9c28cec24096d549c4f3
--- /dev/null
+++ b/third_party/pkg/angular/perf/loop_perf.dart
@@ -0,0 +1,71 @@
+library loop_perf;
+
+import 'package:benchmark_harness/benchmark_harness.dart';
+
+class IterationBenchmark extends BenchmarkBase {
+ List<int> list = new List.generate(1000, (i) => i);
+ Map map;
+ var r = 0;
+ IterationBenchmark(name) : super(name) {
+ map = new Map.fromIterable(list, key: (i) => i, value: (i) => i);
+ }
+}
+
+class ForEach extends IterationBenchmark {
+ ForEach() : super('forEach');
+ run() {
+ var count = 0;
+ list.forEach((int i) => count = count + i);
+ return count;
+ }
+}
+
+class ForEachMap extends IterationBenchmark {
+ ForEachMap() : super('forEachMap');
+ run() {
+ var count = 0;
+ map.forEach((int k, int v) => count = count + k + v);
+ return count;
+ }
+}
+
+class ForIn extends IterationBenchmark {
+ ForIn() : super('for in');
+ run() {
+ var count = 0;
+ for(int item in list) {
+ count = count + item;
+ }
+ return count;
+ }
+}
+
+class ForInMap extends IterationBenchmark {
+ ForInMap() : super('for in Map');
+ run() {
+ var count = 0;
+ for(int key in map.keys) {
+ count = count + key + map[key];
+ }
+ return count;
+ }
+}
+
+class ForLoop extends IterationBenchmark {
+ ForLoop() : super('for loop');
+ run() {
+ int count = 0;
+ for(int i = 0; i < list.length; i++) {
+ count += list[i];
+ }
+ return count;
+ }
+}
+
+void main() {
+ new ForEach().report();
+ new ForIn().report();
+ new ForLoop().report();
+ new ForEachMap().report();
+ new ForInMap().report();
+}

Powered by Google App Engine
This is Rietveld 408576698