@@ -7,65 +7,51 @@ import 'package:benchmark_harness/benchmark_harness.dart';
77import 'shared.dart' ;
88
99Future <void > runBenchmarks (MacroExecutor executor, Uri macroUri) async {
10- final typeDeclarations = {
10+ final introspector = SimpleDefinitionPhaseIntrospector (declarations : {
1111 myClass.identifier: myClass,
1212 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: {
2214 Uri .parse ('dart:core' ): {
2315 'bool' : boolIdentifier,
2416 'int' : intIdentifier,
2517 'Object' : objectIdentifier,
2618 'String' : stringIdentifier,
2719 }
20+ }, constructors: {}, enumValues: {}, fields: {
21+ myClass: myClassFields
22+ }, methods: {
23+ myClass: myClassMethods
2824 });
2925 final identifierDeclarations = {
30- ...typeDeclarations ,
31- for (final constructors in typeIntrospector .constructors.values)
26+ ...introspector.declarations ,
27+ for (final constructors in introspector .constructors.values)
3228 for (final constructor in constructors)
3329 constructor.identifier: constructor,
34- for (final methods in typeIntrospector .methods.values)
30+ for (final methods in introspector .methods.values)
3531 for (final method in methods) method.identifier: method,
36- for (final fields in typeIntrospector .fields.values)
32+ for (final fields in introspector .fields.values)
3733 for (final field in fields) field.identifier: field,
3834 };
3935 final instantiateBenchmark =
4036 DataClassInstantiateBenchmark (executor, macroUri);
4137 await instantiateBenchmark.report ();
4238 final instanceId = instantiateBenchmark.instanceIdentifier;
4339 final typesBenchmark = DataClassTypesPhaseBenchmark (
44- executor, macroUri, identifierResolver, instanceId );
40+ executor, macroUri, instanceId, introspector );
4541 await typesBenchmark.report ();
4642 BuildAugmentationLibraryBenchmark .reportAndPrint (
4743 executor,
4844 [if (typesBenchmark.result != null ) typesBenchmark.result! ],
4945 identifierDeclarations);
5046 final declarationsBenchmark = DataClassDeclarationsPhaseBenchmark (
51- executor,
52- macroUri,
53- identifierResolver,
54- instanceId,
55- typeIntrospector,
56- typeDeclarationResolver);
47+ executor, macroUri, instanceId, introspector);
5748 await declarationsBenchmark.report ();
5849 BuildAugmentationLibraryBenchmark .reportAndPrint (
5950 executor,
6051 [if (declarationsBenchmark.result != null ) declarationsBenchmark.result! ],
6152 identifierDeclarations);
6253 final definitionsBenchmark = DataClassDefinitionPhaseBenchmark (
63- executor,
64- macroUri,
65- identifierResolver,
66- instanceId,
67- typeIntrospector,
68- typeDeclarationResolver);
54+ executor, macroUri, instanceId, introspector);
6955 await definitionsBenchmark.report ();
7056 BuildAugmentationLibraryBenchmark .reportAndPrint (
7157 executor,
@@ -90,88 +76,63 @@ class DataClassInstantiateBenchmark extends AsyncBenchmarkBase {
9076class DataClassTypesPhaseBenchmark extends AsyncBenchmarkBase {
9177 final MacroExecutor executor;
9278 final Uri macroUri;
93- final IdentifierResolver identifierResolver;
9479 final MacroInstanceIdentifier instanceIdentifier;
80+ final TypePhaseIntrospector introspector;
9581 MacroExecutionResult ? result;
9682
97- DataClassTypesPhaseBenchmark (this .executor, this .macroUri,
98- this .identifierResolver , this .instanceIdentifier)
83+ DataClassTypesPhaseBenchmark (
84+ this .executor , this .macroUri, this . instanceIdentifier, this .introspector )
9985 : super ('DataClassTypesPhase' );
10086
10187 Future <void > run () async {
10288 if (instanceIdentifier.shouldExecute (
10389 DeclarationKind .classType, Phase .types)) {
10490 result = await executor.executeTypesPhase (
105- instanceIdentifier, myClass, identifierResolver );
91+ instanceIdentifier, myClass, introspector );
10692 }
10793 }
10894}
10995
11096class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
11197 final MacroExecutor executor;
11298 final Uri macroUri;
113- final IdentifierResolver identifierResolver;
11499 final MacroInstanceIdentifier instanceIdentifier;
115- final TypeIntrospector typeIntrospector;
116- final TypeDeclarationResolver typeDeclarationResolver;
100+ final DeclarationPhaseIntrospector introspector;
117101
118102 MacroExecutionResult ? result;
119103
120104 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)
127106 : super ('DataClassDeclarationsPhase' );
128107
129108 Future <void > run () async {
130109 result = null ;
131110 if (instanceIdentifier.shouldExecute (
132111 DeclarationKind .classType, Phase .declarations)) {
133112 result = await executor.executeDeclarationsPhase (
134- instanceIdentifier,
135- myClass,
136- identifierResolver,
137- typeDeclarationResolver,
138- SimpleTypeResolver (),
139- typeIntrospector);
113+ instanceIdentifier, myClass, introspector);
140114 }
141115 }
142116}
143117
144118class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
145119 final MacroExecutor executor;
146120 final Uri macroUri;
147- final IdentifierResolver identifierResolver;
148121 final MacroInstanceIdentifier instanceIdentifier;
149- final TypeIntrospector typeIntrospector;
150- final TypeDeclarationResolver typeDeclarationResolver;
122+ final DefinitionPhaseIntrospector introspector;
151123
152124 MacroExecutionResult ? result;
153125
154126 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)
161128 : super ('DataClassDefinitionPhase' );
162129
163130 Future <void > run () async {
164131 result = null ;
165132 if (instanceIdentifier.shouldExecute (
166133 DeclarationKind .classType, Phase .definitions)) {
167134 result = await executor.executeDefinitionsPhase (
168- instanceIdentifier,
169- myClass,
170- identifierResolver,
171- typeDeclarationResolver,
172- const SimpleTypeResolver (),
173- typeIntrospector,
174- const FakeTypeInferrer ());
135+ instanceIdentifier, myClass, introspector);
175136 }
176137 }
177138}
@@ -182,6 +143,7 @@ final myClass = IntrospectableClassDeclarationImpl(
182143 id: RemoteInstance .uniqueId,
183144 identifier: myClassIdentifier,
184145 library: fooLibrary,
146+ metadata: [],
185147 interfaces: [],
186148 hasAbstract: false ,
187149 hasBase: false ,
@@ -205,6 +167,7 @@ final myClassFields = [
205167 id: RemoteInstance .uniqueId,
206168 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myString' ),
207169 library: fooLibrary,
170+ metadata: [],
208171 isExternal: false ,
209172 isFinal: true ,
210173 isLate: false ,
@@ -215,6 +178,7 @@ final myClassFields = [
215178 id: RemoteInstance .uniqueId,
216179 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myBool' ),
217180 library: fooLibrary,
181+ metadata: [],
218182 isExternal: false ,
219183 isFinal: true ,
220184 isLate: false ,
@@ -228,6 +192,7 @@ final myClassMethods = [
228192 id: RemoteInstance .uniqueId,
229193 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: '==' ),
230194 library: fooLibrary,
195+ metadata: [],
231196 isAbstract: false ,
232197 isExternal: false ,
233198 isGetter: false ,
@@ -240,6 +205,7 @@ final myClassMethods = [
240205 id: RemoteInstance .uniqueId,
241206 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'other' ),
242207 library: fooLibrary,
208+ metadata: [],
243209 isNamed: false ,
244210 isRequired: true ,
245211 type: NamedTypeAnnotationImpl (
@@ -257,6 +223,7 @@ final myClassMethods = [
257223 id: RemoteInstance .uniqueId,
258224 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'hashCode' ),
259225 library: fooLibrary,
226+ metadata: [],
260227 isAbstract: false ,
261228 isExternal: false ,
262229 isOperator: false ,
@@ -273,6 +240,7 @@ final myClassMethods = [
273240 id: RemoteInstance .uniqueId,
274241 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'toString' ),
275242 library: fooLibrary,
243+ metadata: [],
276244 isAbstract: false ,
277245 isExternal: false ,
278246 isGetter: false ,
0 commit comments