@@ -130,236 +130,260 @@ static CastingPerf()
130
130
orvt = new FooORVT [ NUM_ARRAY_ELEMENTS ] ;
131
131
}
132
132
133
- [ Benchmark ]
133
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
134
134
public static void ObjFooIsObj ( )
135
135
{
136
136
foreach ( var iteration in Benchmark . Iterations )
137
137
using ( iteration . StartMeasurement ( ) )
138
- o = foo ;
138
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
139
+ o = foo ;
139
140
}
140
141
141
- [ Benchmark ]
142
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
142
143
public static void ObjFooIsObj2 ( )
143
144
{
144
145
foreach ( var iteration in Benchmark . Iterations )
145
146
using ( iteration . StartMeasurement ( ) )
146
- o_ar = foo ;
147
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
148
+ o_ar = foo ;
147
149
}
148
150
149
- [ Benchmark ]
151
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
150
152
public static void ObjObjIsFoo ( )
151
153
{
152
154
o = foo ;
153
155
154
156
foreach ( var iteration in Benchmark . Iterations )
155
157
using ( iteration . StartMeasurement ( ) )
156
- o_ar = ( Object [ ] ) o ;
158
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
159
+ o_ar = ( Object [ ] ) o ;
157
160
}
158
161
159
- [ Benchmark ]
162
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
160
163
public static void FooObjIsFoo ( )
161
164
{
162
165
o = foo ;
163
166
164
167
foreach ( var iteration in Benchmark . Iterations )
165
168
using ( iteration . StartMeasurement ( ) )
166
- f = ( Foo [ ] ) o ;
169
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
170
+ f = ( Foo [ ] ) o ;
167
171
}
168
172
169
- [ Benchmark ]
173
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
170
174
public static void FooObjIsFoo2 ( )
171
175
{
172
176
o_ar = foo ;
173
177
174
178
foreach ( var iteration in Benchmark . Iterations )
175
179
using ( iteration . StartMeasurement ( ) )
176
- f = ( Foo [ ] ) o_ar ;
180
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
181
+ f = ( Foo [ ] ) o_ar ;
177
182
}
178
183
179
- [ Benchmark ]
184
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
180
185
public static void FooObjIsNull ( )
181
186
{
182
187
foreach ( var iteration in Benchmark . Iterations )
183
188
using ( iteration . StartMeasurement ( ) )
184
- o = ( Foo [ ] ) n ;
189
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
190
+ o = ( Foo [ ] ) n ;
185
191
}
186
192
187
- [ Benchmark ]
193
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
188
194
public static void FooObjIsDescendant ( )
189
195
{
190
196
o = foo_5 ;
191
197
192
198
foreach ( var iteration in Benchmark . Iterations )
193
199
using ( iteration . StartMeasurement ( ) )
194
- f = ( Foo [ ] ) o ;
200
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
201
+ f = ( Foo [ ] ) o ;
195
202
}
196
203
197
- [ Benchmark ]
204
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
198
205
public static void IFooFooIsIFoo ( )
199
206
{
200
207
foreach ( var iteration in Benchmark . Iterations )
201
208
using ( iteration . StartMeasurement ( ) )
202
- ifo = foo ;
209
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
210
+ ifo = foo ;
203
211
}
204
212
205
- [ Benchmark ]
213
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
206
214
public static void IFooObjIsIFoo ( )
207
215
{
208
216
o = foo ;
209
217
210
218
foreach ( var iteration in Benchmark . Iterations )
211
219
using ( iteration . StartMeasurement ( ) )
212
- ifo = ( IFoo [ ] ) o ;
220
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
221
+ ifo = ( IFoo [ ] ) o ;
213
222
}
214
223
215
- [ Benchmark ]
224
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
216
225
public static void IFooObjIsIFooInterAlia ( )
217
226
{
218
227
o = foo2 ;
219
228
220
229
foreach ( var iteration in Benchmark . Iterations )
221
230
using ( iteration . StartMeasurement ( ) )
222
- if_5 = ( IFoo_5 [ ] ) o ;
231
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
232
+ if_5 = ( IFoo_5 [ ] ) o ;
223
233
}
224
234
225
- [ Benchmark ]
235
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
226
236
public static void IFooObjIsDescendantOfIFoo ( )
227
237
{
228
238
o = foo_5 ;
229
239
230
240
foreach ( var iteration in Benchmark . Iterations )
231
241
using ( iteration . StartMeasurement ( ) )
232
- ifo = ( IFoo [ ] ) o ;
242
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
243
+ ifo = ( IFoo [ ] ) o ;
233
244
}
234
245
235
- [ Benchmark ]
246
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
236
247
public static void ObjInt ( )
237
248
{
238
249
foreach ( var iteration in Benchmark . Iterations )
239
250
using ( iteration . StartMeasurement ( ) )
240
- o = ( Object ) j ;
251
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
252
+ o = ( Object ) j ;
241
253
}
242
254
243
- [ Benchmark ]
255
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
244
256
public static void IntObj ( )
245
257
{
246
258
o = ( Object ) j ;
247
259
248
260
foreach ( var iteration in Benchmark . Iterations )
249
261
using ( iteration . StartMeasurement ( ) )
250
- k = ( int [ ] ) o ;
262
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
263
+ k = ( int [ ] ) o ;
251
264
}
252
265
253
- [ Benchmark ]
266
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
254
267
public static void ObjScalarValueType ( )
255
268
{
256
269
foreach ( var iteration in Benchmark . Iterations )
257
270
using ( iteration . StartMeasurement ( ) )
258
- o = svt ;
271
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
272
+ o = svt ;
259
273
}
260
274
261
- [ Benchmark ]
275
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
262
276
public static void ScalarValueTypeObj ( )
263
277
{
264
278
o = svt ;
265
279
266
280
foreach ( var iteration in Benchmark . Iterations )
267
281
using ( iteration . StartMeasurement ( ) )
268
- svt = ( FooSVT [ ] ) o ;
282
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
283
+ svt = ( FooSVT [ ] ) o ;
269
284
}
270
285
271
- [ Benchmark ]
286
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
272
287
public static void ObjObjrefValueType ( )
273
288
{
274
289
foreach ( var iteration in Benchmark . Iterations )
275
290
using ( iteration . StartMeasurement ( ) )
276
- o = ( Object ) orvt ;
291
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
292
+ o = ( Object ) orvt ;
277
293
}
278
294
279
- [ Benchmark ]
295
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
280
296
public static void ObjrefValueTypeObj ( )
281
297
{
282
298
o = ( Object ) orvt ;
283
299
284
300
foreach ( var iteration in Benchmark . Iterations )
285
301
using ( iteration . StartMeasurement ( ) )
286
- orvt = ( FooORVT [ ] ) o ;
302
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
303
+ orvt = ( FooORVT [ ] ) o ;
287
304
}
288
305
289
- [ Benchmark ]
306
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
290
307
public static void FooObjCastIfIsa ( )
291
308
{
292
309
o = foo ;
293
310
294
311
foreach ( var iteration in Benchmark . Iterations )
295
312
using ( iteration . StartMeasurement ( ) )
296
- if ( o is Foo [ ] )
297
- f = ( Foo [ ] ) o ;
313
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
314
+ if ( o is Foo [ ] )
315
+ f = ( Foo [ ] ) o ;
298
316
}
299
317
300
- [ Benchmark ]
318
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
301
319
public static bool CheckObjIsInterfaceYes ( )
302
320
{
303
321
bool res = false ;
304
322
Object obj = new MyClass1 ( ) ;
305
323
foreach ( var iteration in Benchmark . Iterations )
306
324
using ( iteration . StartMeasurement ( ) )
307
- res = obj is IMyInterface1 ;
325
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
326
+ res = obj is IMyInterface1 ;
308
327
return res ;
309
328
}
310
329
311
- [ Benchmark ]
330
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
312
331
public static bool CheckObjIsInterfaceNo ( )
313
332
{
314
333
bool res = false ;
315
334
Object obj = new MyClass2 ( ) ;
316
335
foreach ( var iteration in Benchmark . Iterations )
317
336
using ( iteration . StartMeasurement ( ) )
318
- res = obj is IMyInterface1 ;
337
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
338
+ res = obj is IMyInterface1 ;
319
339
return res ;
320
340
}
321
341
322
- [ Benchmark ]
342
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
323
343
public static bool CheckIsInstAnyIsInterfaceYes ( )
324
344
{
325
345
bool res = false ;
326
346
Object obj = new MyClass4 < List < string > > ( ) ;
327
347
foreach ( var iteration in Benchmark . Iterations )
328
348
using ( iteration . StartMeasurement ( ) )
329
- res = obj is IMyInterface1 ;
349
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
350
+ res = obj is IMyInterface1 ;
330
351
return res ;
331
352
}
332
353
333
- [ Benchmark ]
354
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
334
355
public static bool CheckIsInstAnyIsInterfaceNo ( )
335
356
{
336
357
bool res = false ;
337
358
Object obj = new MyClass4 < List < string > > ( ) ;
338
359
foreach ( var iteration in Benchmark . Iterations )
339
360
using ( iteration . StartMeasurement ( ) )
340
- res = obj is IMyInterface2 ;
361
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
362
+ res = obj is IMyInterface2 ;
341
363
return res ;
342
364
}
343
365
344
- [ Benchmark ]
366
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
345
367
public static bool CheckArrayIsInterfaceYes ( )
346
368
{
347
369
bool res = false ;
348
370
Object [ ] arr = new MyClass1 [ 5 ] ;
349
371
foreach ( var iteration in Benchmark . Iterations )
350
372
using ( iteration . StartMeasurement ( ) )
351
- res = arr is IMyInterface1 [ ] ;
373
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
374
+ res = arr is IMyInterface1 [ ] ;
352
375
return res ;
353
376
}
354
377
355
- [ Benchmark ]
378
+ [ Benchmark ( InnerIterationCount = 100000 ) ]
356
379
public static bool CheckArrayIsInterfaceNo ( )
357
380
{
358
381
bool res = false ;
359
382
Object [ ] arr = new MyClass2 [ 5 ] ;
360
383
foreach ( var iteration in Benchmark . Iterations )
361
384
using ( iteration . StartMeasurement ( ) )
362
- res = arr is IMyInterface1 [ ] ;
385
+ for ( int i = 0 ; i < Benchmark . InnerIterationCount ; i ++ )
386
+ res = arr is IMyInterface1 [ ] ;
363
387
return res ;
364
388
}
365
389
}
0 commit comments