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

Side by Side Diff: third_party/pkg/angular/perf/invoke_perf.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library angular.perf.invoke; 1 library angular.perf.invoke;
2 2
3 import '_perf.dart'; 3 import 'package:benchmark_harness/benchmark_harness.dart';
4 import 'dart:async';
5 4
6 main() { 5 main() {
7 var handleDirect = (a, b, c) => a; 6 new MonomorphicClosure0ListInvoke().report();
8 var wrap = new Wrap(); 7 new PolymorphicMethod0ListInvoke().report();
9 var handleDirectNamed = ({a, b, c}) => a; 8 new PolymorphicClosure0ListInvoke().report();
10 var handleIndirect = (e) => e.a; 9 new PolymorphicMethod1ListInvoke().report();
11 var streamC = new StreamController(sync:true); 10 new PolymorphicClosure1ListInvoke().report();
12 var stream = streamC.stream..listen(handleIndirect);
13
14 time('direct', () => handleDirect(1, 2, 3) );
15 time('.call', () => wrap(1, 2, 3) );
16 time('directNamed', () => handleDirectNamed(a:1, b:2, c:3) );
17 time('indirect', () => handleIndirect(new Container(1, 2, 3)) );
18 time('stream', () => streamC.add(new Container(1, 2, 3)));
19 } 11 }
20 12
21 class Container { 13 var closure0Factory = [
22 var a; 14 () => () => 0,
23 var b; 15 () => () => 1,
24 var c; 16 () => () => 2,
17 () => () => 3,
18 () => () => 4,
19 () => () => 5,
20 () => () => 6,
21 () => () => 7,
22 () => () => 8,
23 () => () => 9,
24 ];
25 25
26 Container(this.a, this.b, this.c); 26 var closure1Factory = [
27 () => (i) => 0,
28 () => (i) => 1,
29 () => (i) => 2,
30 () => (i) => 3,
31 () => (i) => 4,
32 () => (i) => 5,
33 () => (i) => 6,
34 () => (i) => 7,
35 () => (i) => 8,
36 () => (i) => 9,
37 ];
38
39 var instanceFactory = [
40 () => new Obj0(),
41 () => new Obj1(),
42 () => new Obj2(),
43 () => new Obj3(),
44 () => new Obj4(),
45 () => new Obj5(),
46 () => new Obj6(),
47 () => new Obj7(),
48 () => new Obj8(),
49 () => new Obj9(),
50 ];
51
52 class Obj0 { method0() => 0; method1(i) => 0; }
53 class Obj1 { method0() => 1; method1(i) => 1; }
54 class Obj2 { method0() => 2; method1(i) => 2; }
55 class Obj3 { method0() => 3; method1(i) => 3; }
56 class Obj4 { method0() => 4; method1(i) => 4; }
57 class Obj5 { method0() => 5; method1(i) => 5; }
58 class Obj6 { method0() => 6; method1(i) => 6; }
59 class Obj7 { method0() => 7; method1(i) => 7; }
60 class Obj8 { method0() => 8; method1(i) => 8; }
61 class Obj9 { method0() => 9; method1(i) => 9; }
62
63 class PolymorphicClosure0ListInvoke extends BenchmarkBase {
64 PolymorphicClosure0ListInvoke() : super('PolymorphicClosure0ListInvoke');
65
66 var list = new List.generate(10000, (i) => closure0Factory[i%10]());
67
68 run() {
69 int sum = 0;
70 for(var i=0; i < list.length; i++) {
71 sum += list[i]();
72 }
73 return sum;
74 }
27 } 75 }
28 76
29 class Wrap { 77 class MonomorphicClosure0ListInvoke extends BenchmarkBase {
30 call(a, b, c) => a + b + c; 78 MonomorphicClosure0ListInvoke() : super('MonomorphicClosure0ListInvoke');
79
80 var list = new List.generate(10000, (i) => closure0Factory[0]());
81
82 run() {
83 int sum = 0;
84 for(var i=0; i < list.length; i++) {
85 sum += list[i]();
86 }
87 return sum;
88 }
31 } 89 }
90
91 class PolymorphicClosure1ListInvoke extends BenchmarkBase {
92 PolymorphicClosure1ListInvoke() : super('PolymorphicClosure1ListInvoke');
93
94 var list = new List.generate(10000, (i) => closure1Factory[i%10]());
95
96 run() {
97 int sum = 0;
98 for(var i=0; i < list.length; i++) {
99 sum += list[i](i);
100 }
101 return sum;
102 }
103 }
104
105 class PolymorphicMethod0ListInvoke extends BenchmarkBase {
106 PolymorphicMethod0ListInvoke() : super('PolymorphicMethod0ListInvoke');
107
108 var list = new List.generate(10000, (i) => instanceFactory[i%10]());
109
110 run() {
111 int sum = 0;
112 for(var i=0; i < list.length; i++) {
113 sum += list[i].method0();
114 }
115 return sum;
116 }
117 }
118
119 class PolymorphicMethod1ListInvoke extends BenchmarkBase {
120 PolymorphicMethod1ListInvoke() : super('PolymorphicMethod1ListInvoke');
121
122 var list = new List.generate(10000, (i) => instanceFactory[i%10]());
123
124 run() {
125 int sum = 0;
126 for(var i=0; i < list.length; i++) {
127 sum += list[i].method1(i);
128 }
129 return sum;
130 }
131 }
132
OLDNEW
« no previous file with comments | « third_party/pkg/angular/perf/dom/compile_perf.dart ('k') | third_party/pkg/angular/perf/mirror_perf.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698