@@ -29,6 +29,7 @@ public class Invoke
29
29
private static MethodInvoker s_method_invoker ;
30
30
private static MethodInvoker s_method_int_string_struct_class_invoker ;
31
31
private static MethodInvoker s_method_byref_int_string_struct_class_invoker ;
32
+ private static MethodInvoker s_method_byref_int_string_struct_class_bool_invoker ;
32
33
private static ConstructorInvoker s_ctor_int_string_struct_class_invoker ;
33
34
private static ConstructorInvoker s_ctor_NoParams_invoker ;
34
35
#endif
@@ -100,6 +101,7 @@ public void Setup()
100
101
s_method_invoker = MethodInvoker . Create ( s_method ) ;
101
102
s_method_int_string_struct_class_invoker = MethodInvoker . Create ( s_method_int_string_struct_class ) ;
102
103
s_method_byref_int_string_struct_class_invoker = MethodInvoker . Create ( s_method_byref_int_string_struct_class ) ;
104
+ s_method_byref_int_string_struct_class_bool_invoker = MethodInvoker . Create ( s_method_byref_int_string_struct_class_bool ) ;
103
105
s_ctor_int_string_struct_class_invoker = ConstructorInvoker . Create ( s_ctor_int_string_struct_class ) ;
104
106
s_ctor_NoParams_invoker = ConstructorInvoker . Create ( typeof ( MyClass ) . GetConstructor ( Array . Empty < Type > ( ) ) ) ;
105
107
#endif
@@ -187,23 +189,21 @@ public void StaticMethod4_int_string_struct_class()
187
189
[ Benchmark ( OperationsPerInvoke = Iterations ) ]
188
190
public void StaticMethod4_int_string_struct_class_MethodInvoker ( )
189
191
{
190
- // To make the test more comparable to the MethodBase tests, we need to pre-box the value types.
191
- object boxedInt = 42 ;
192
- object boxedStruct = default ( MyBlittableStruct ) ;
192
+ // To make the test more comparable to the MethodBase tests, set up the references and pre-boxed types.
193
+ object boxedInt = s_args4 [ 0 ] ;
194
+ object stringRef = s_args4 [ 1 ] ;
195
+ object boxedStruct = s_args4 [ 2 ] ;
196
+ object myClassRef = s_args4 [ 3 ] ;
193
197
194
198
for ( int i = 0 ; i < Iterations ; i ++ )
195
199
{
196
- s_method_int_string_struct_class_invoker . Invoke ( null , boxedInt , "Hello" , boxedStruct , s_MyClass ) ;
200
+ s_method_int_string_struct_class_invoker . Invoke ( null , boxedInt , stringRef , boxedStruct , myClassRef ) ;
197
201
}
198
202
}
199
203
200
204
[ Benchmark ( OperationsPerInvoke = Iterations ) ]
201
205
public void StaticMethod4_int_string_struct_class_MethodInvokerWithSpan ( )
202
206
{
203
- // To make the test more comparable to the MethodBase tests, we need to pre-box the value types.
204
- object boxedInt = 42 ;
205
- object boxedStruct = default ( MyBlittableStruct ) ;
206
-
207
207
for ( int i = 0 ; i < Iterations ; i ++ )
208
208
{
209
209
s_method_int_string_struct_class_invoker . Invoke ( null , new Span < object > ( s_args4 ) ) ;
@@ -224,13 +224,15 @@ public void StaticMethod4_ByRefParams_int_string_struct_class()
224
224
[ Benchmark ( OperationsPerInvoke = Iterations ) ]
225
225
public void StaticMethod4_ByRefParams_int_string_struct_class_MethodInvoker ( )
226
226
{
227
- // To make the test more comparable to the MethodBase tests, we need to pre-box the value types.
228
- object boxedInt = 42 ;
229
- object boxedStruct = default ( MyBlittableStruct ) ;
227
+ // To make the test more comparable to the MethodBase tests, set up the references and pre-boxed types.
228
+ object boxedInt = s_args4 [ 0 ] ;
229
+ object stringRef = s_args4 [ 1 ] ;
230
+ object boxedStruct = s_args4 [ 2 ] ;
231
+ object myClassRef = s_args4 [ 3 ] ;
230
232
231
233
for ( int i = 0 ; i < Iterations ; i ++ )
232
234
{
233
- s_method_byref_int_string_struct_class_invoker . Invoke ( null , boxedInt , "Hello" , boxedStruct , s_MyClass ) ;
235
+ s_method_byref_int_string_struct_class_invoker . Invoke ( null , boxedInt , stringRef , boxedStruct , myClassRef ) ;
234
236
}
235
237
}
236
238
#endif
@@ -245,6 +247,17 @@ public void StaticMethod5_ByRefParams_int_string_struct_class_bool()
245
247
}
246
248
}
247
249
250
+ #if NET8_0_OR_GREATER
251
+ [ Benchmark ( OperationsPerInvoke = Iterations ) ]
252
+ public void StaticMethod5_ByRefParams_int_string_struct_class_bool_MethodInvoker ( )
253
+ {
254
+ for ( int i = 0 ; i < Iterations ; i ++ )
255
+ {
256
+ s_method_byref_int_string_struct_class_bool_invoker . Invoke ( null , new Span < object > ( s_args5 ) ) ;
257
+ }
258
+ }
259
+ #endif
260
+
248
261
[ Benchmark ( OperationsPerInvoke = Iterations ) ]
249
262
public void Ctor0_NoParams ( )
250
263
{
@@ -301,13 +314,15 @@ public void Ctor4_int_string_struct_class()
301
314
[ Benchmark ( OperationsPerInvoke = Iterations ) ]
302
315
public void Ctor4_int_string_struct_class_ConstructorInvoker ( )
303
316
{
304
- // To make the test more comparable to the MethodBase tests, we need to pre-box the value types.
305
- object boxedInt = 42 ;
306
- object boxedStruct = default ( MyBlittableStruct ) ;
317
+ // To make the test more comparable to the MethodBase tests, set up the references and pre-boxed types.
318
+ object boxedInt = s_args4 [ 0 ] ;
319
+ object stringRef = s_args4 [ 1 ] ;
320
+ object boxedStruct = s_args4 [ 2 ] ;
321
+ object myClassRef = s_args4 [ 3 ] ;
307
322
308
323
for ( int i = 0 ; i < Iterations ; i ++ )
309
324
{
310
- s_ctor_int_string_struct_class_invoker . Invoke ( boxedInt , "Hello" , boxedStruct , s_MyClass ) ;
325
+ s_ctor_int_string_struct_class_invoker . Invoke ( boxedInt , stringRef , boxedStruct , myClassRef ) ;
311
326
}
312
327
}
313
328
#endif
0 commit comments