@@ -7,65 +7,51 @@ import 'package:benchmark_harness/benchmark_harness.dart';
7
7
import 'shared.dart' ;
8
8
9
9
Future <void > runBenchmarks (MacroExecutor executor, Uri macroUri) async {
10
- final typeDeclarations = {
10
+ final introspector = SimpleDefinitionPhaseIntrospector (declarations : {
11
11
myClass.identifier: myClass,
12
12
objectClass.identifier: objectClass
13
- };
14
- final typeIntrospector = SimpleTypeIntrospector (
15
- constructors: {},
16
- enumValues: {},
17
- fields: {myClass: myClassFields},
18
- methods: {myClass: myClassMethods});
19
- final typeDeclarationResolver =
20
- SimpleTypeDeclarationResolver (typeDeclarations);
21
- final identifierResolver = SimpleIdentifierResolver ({
13
+ }, identifiers: {
22
14
Uri .parse ('dart:core' ): {
23
15
'bool' : boolIdentifier,
24
16
'int' : intIdentifier,
25
17
'Object' : objectIdentifier,
26
18
'String' : stringIdentifier,
27
19
}
20
+ }, constructors: {}, enumValues: {}, fields: {
21
+ myClass: myClassFields
22
+ }, methods: {
23
+ myClass: myClassMethods
28
24
});
29
25
final identifierDeclarations = {
30
- ...typeDeclarations ,
31
- for (final constructors in typeIntrospector .constructors.values)
26
+ ...introspector.declarations ,
27
+ for (final constructors in introspector .constructors.values)
32
28
for (final constructor in constructors)
33
29
constructor.identifier: constructor,
34
- for (final methods in typeIntrospector .methods.values)
30
+ for (final methods in introspector .methods.values)
35
31
for (final method in methods) method.identifier: method,
36
- for (final fields in typeIntrospector .fields.values)
32
+ for (final fields in introspector .fields.values)
37
33
for (final field in fields) field.identifier: field,
38
34
};
39
35
final instantiateBenchmark =
40
36
DataClassInstantiateBenchmark (executor, macroUri);
41
37
await instantiateBenchmark.report ();
42
38
final instanceId = instantiateBenchmark.instanceIdentifier;
43
39
final typesBenchmark = DataClassTypesPhaseBenchmark (
44
- executor, macroUri, identifierResolver, instanceId );
40
+ executor, macroUri, instanceId, introspector );
45
41
await typesBenchmark.report ();
46
42
BuildAugmentationLibraryBenchmark .reportAndPrint (
47
43
executor,
48
44
[if (typesBenchmark.result != null ) typesBenchmark.result! ],
49
45
identifierDeclarations);
50
46
final declarationsBenchmark = DataClassDeclarationsPhaseBenchmark (
51
- executor,
52
- macroUri,
53
- identifierResolver,
54
- instanceId,
55
- typeIntrospector,
56
- typeDeclarationResolver);
47
+ executor, macroUri, instanceId, introspector);
57
48
await declarationsBenchmark.report ();
58
49
BuildAugmentationLibraryBenchmark .reportAndPrint (
59
50
executor,
60
51
[if (declarationsBenchmark.result != null ) declarationsBenchmark.result! ],
61
52
identifierDeclarations);
62
53
final definitionsBenchmark = DataClassDefinitionPhaseBenchmark (
63
- executor,
64
- macroUri,
65
- identifierResolver,
66
- instanceId,
67
- typeIntrospector,
68
- typeDeclarationResolver);
54
+ executor, macroUri, instanceId, introspector);
69
55
await definitionsBenchmark.report ();
70
56
BuildAugmentationLibraryBenchmark .reportAndPrint (
71
57
executor,
@@ -90,88 +76,63 @@ class DataClassInstantiateBenchmark extends AsyncBenchmarkBase {
90
76
class DataClassTypesPhaseBenchmark extends AsyncBenchmarkBase {
91
77
final MacroExecutor executor;
92
78
final Uri macroUri;
93
- final IdentifierResolver identifierResolver;
94
79
final MacroInstanceIdentifier instanceIdentifier;
80
+ final TypePhaseIntrospector introspector;
95
81
MacroExecutionResult ? result;
96
82
97
- DataClassTypesPhaseBenchmark (this .executor, this .macroUri,
98
- this .identifierResolver , this .instanceIdentifier)
83
+ DataClassTypesPhaseBenchmark (
84
+ this .executor , this .macroUri, this . instanceIdentifier, this .introspector )
99
85
: super ('DataClassTypesPhase' );
100
86
101
87
Future <void > run () async {
102
88
if (instanceIdentifier.shouldExecute (
103
89
DeclarationKind .classType, Phase .types)) {
104
90
result = await executor.executeTypesPhase (
105
- instanceIdentifier, myClass, identifierResolver );
91
+ instanceIdentifier, myClass, introspector );
106
92
}
107
93
}
108
94
}
109
95
110
96
class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
111
97
final MacroExecutor executor;
112
98
final Uri macroUri;
113
- final IdentifierResolver identifierResolver;
114
99
final MacroInstanceIdentifier instanceIdentifier;
115
- final TypeIntrospector typeIntrospector;
116
- final TypeDeclarationResolver typeDeclarationResolver;
100
+ final DeclarationPhaseIntrospector introspector;
117
101
118
102
MacroExecutionResult ? result;
119
103
120
104
DataClassDeclarationsPhaseBenchmark (
121
- this .executor,
122
- this .macroUri,
123
- this .identifierResolver,
124
- this .instanceIdentifier,
125
- this .typeIntrospector,
126
- this .typeDeclarationResolver)
105
+ this .executor, this .macroUri, this .instanceIdentifier, this .introspector)
127
106
: super ('DataClassDeclarationsPhase' );
128
107
129
108
Future <void > run () async {
130
109
result = null ;
131
110
if (instanceIdentifier.shouldExecute (
132
111
DeclarationKind .classType, Phase .declarations)) {
133
112
result = await executor.executeDeclarationsPhase (
134
- instanceIdentifier,
135
- myClass,
136
- identifierResolver,
137
- typeDeclarationResolver,
138
- SimpleTypeResolver (),
139
- typeIntrospector);
113
+ instanceIdentifier, myClass, introspector);
140
114
}
141
115
}
142
116
}
143
117
144
118
class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
145
119
final MacroExecutor executor;
146
120
final Uri macroUri;
147
- final IdentifierResolver identifierResolver;
148
121
final MacroInstanceIdentifier instanceIdentifier;
149
- final TypeIntrospector typeIntrospector;
150
- final TypeDeclarationResolver typeDeclarationResolver;
122
+ final DefinitionPhaseIntrospector introspector;
151
123
152
124
MacroExecutionResult ? result;
153
125
154
126
DataClassDefinitionPhaseBenchmark (
155
- this .executor,
156
- this .macroUri,
157
- this .identifierResolver,
158
- this .instanceIdentifier,
159
- this .typeIntrospector,
160
- this .typeDeclarationResolver)
127
+ this .executor, this .macroUri, this .instanceIdentifier, this .introspector)
161
128
: super ('DataClassDefinitionPhase' );
162
129
163
130
Future <void > run () async {
164
131
result = null ;
165
132
if (instanceIdentifier.shouldExecute (
166
133
DeclarationKind .classType, Phase .definitions)) {
167
134
result = await executor.executeDefinitionsPhase (
168
- instanceIdentifier,
169
- myClass,
170
- identifierResolver,
171
- typeDeclarationResolver,
172
- const SimpleTypeResolver (),
173
- typeIntrospector,
174
- const FakeTypeInferrer ());
135
+ instanceIdentifier, myClass, introspector);
175
136
}
176
137
}
177
138
}
@@ -182,6 +143,7 @@ final myClass = IntrospectableClassDeclarationImpl(
182
143
id: RemoteInstance .uniqueId,
183
144
identifier: myClassIdentifier,
184
145
library: fooLibrary,
146
+ metadata: [],
185
147
interfaces: [],
186
148
hasAbstract: false ,
187
149
hasBase: false ,
@@ -205,6 +167,7 @@ final myClassFields = [
205
167
id: RemoteInstance .uniqueId,
206
168
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myString' ),
207
169
library: fooLibrary,
170
+ metadata: [],
208
171
isExternal: false ,
209
172
isFinal: true ,
210
173
isLate: false ,
@@ -215,6 +178,7 @@ final myClassFields = [
215
178
id: RemoteInstance .uniqueId,
216
179
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myBool' ),
217
180
library: fooLibrary,
181
+ metadata: [],
218
182
isExternal: false ,
219
183
isFinal: true ,
220
184
isLate: false ,
@@ -228,6 +192,7 @@ final myClassMethods = [
228
192
id: RemoteInstance .uniqueId,
229
193
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: '==' ),
230
194
library: fooLibrary,
195
+ metadata: [],
231
196
isAbstract: false ,
232
197
isExternal: false ,
233
198
isGetter: false ,
@@ -240,6 +205,7 @@ final myClassMethods = [
240
205
id: RemoteInstance .uniqueId,
241
206
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'other' ),
242
207
library: fooLibrary,
208
+ metadata: [],
243
209
isNamed: false ,
244
210
isRequired: true ,
245
211
type: NamedTypeAnnotationImpl (
@@ -257,6 +223,7 @@ final myClassMethods = [
257
223
id: RemoteInstance .uniqueId,
258
224
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'hashCode' ),
259
225
library: fooLibrary,
226
+ metadata: [],
260
227
isAbstract: false ,
261
228
isExternal: false ,
262
229
isOperator: false ,
@@ -273,6 +240,7 @@ final myClassMethods = [
273
240
id: RemoteInstance .uniqueId,
274
241
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'toString' ),
275
242
library: fooLibrary,
243
+ metadata: [],
276
244
isAbstract: false ,
277
245
isExternal: false ,
278
246
isGetter: false ,
0 commit comments