@@ -82,15 +82,17 @@ public class AccurateSurvived
82
82
public byte [ ] bytes64 ;
83
83
public Task < int > task ;
84
84
85
- [ GlobalSetup ( Targets = new string [ ] { nameof ( EightBytesArrayNoAllocate ) , nameof ( SixtyFourBytesArrayNoAllocate ) } ) ]
85
+ [ GlobalSetup ( Targets = new string [ ] { nameof ( EightBytesArrayNoAllocate ) , nameof ( SixtyFourBytesArrayNoAllocate ) , nameof ( TaskNoAllocate ) } ) ]
86
86
public void SetupNoAllocate ( )
87
87
{
88
88
bytes8 = new byte [ 8 ] ;
89
89
bytes64 = new byte [ 64 ] ;
90
+ task = Task . FromResult ( default ( int ) ) ;
90
91
}
91
92
92
93
[ Benchmark ] public byte [ ] EightBytesArrayNoAllocate ( ) => bytes8 ;
93
94
[ Benchmark ] public byte [ ] SixtyFourBytesArrayNoAllocate ( ) => bytes64 ;
95
+ [ Benchmark ] public Task < int > TaskNoAllocate ( ) => task ;
94
96
95
97
96
98
[ Benchmark ] public void EightBytesArraySurvive ( ) => bytes8 = new byte [ 8 ] ;
@@ -118,6 +120,7 @@ public void MemoryDiagnoserSurvivedIsAccurate(IToolchain toolchain)
118
120
119
121
{ nameof ( AccurateSurvived . EightBytesArrayNoAllocate ) , 0 } ,
120
122
{ nameof ( AccurateSurvived . SixtyFourBytesArrayNoAllocate ) , 0 } ,
123
+ { nameof ( AccurateSurvived . TaskNoAllocate ) , 0 } ,
121
124
122
125
{ nameof ( AccurateSurvived . EightBytesArraySurvive ) , 8 + objectAllocationOverhead + arraySizeOverhead } ,
123
126
{ nameof ( AccurateSurvived . SixtyFourBytesArraySurvive ) , 64 + objectAllocationOverhead + arraySizeOverhead } ,
@@ -401,9 +404,7 @@ private void AssertSurvived(IToolchain toolchain, Type benchmarkType, Dictionary
401
404
{
402
405
// Core has survived memory measurement problems.
403
406
// See https://github.com/dotnet/runtime/issues/45446
404
- if ( toolchain is CsProjCoreToolchain
405
- || ( toolchain . IsInProcess && RuntimeInformation . IsNetCore )
406
- || toolchain is CoreRtToolchain ) // CoreRt actually does measure accurately in a normal benchmark run, but doesn't with the specific version used in these tests.
407
+ if ( toolchain is CsProjCoreToolchain || ( toolchain . IsInProcess && RuntimeInformation . IsNetCore ) )
407
408
return ;
408
409
409
410
var config = CreateConfig ( toolchain , MemoryDiagnoser . WithSurvived ) ;
@@ -413,6 +414,11 @@ private void AssertSurvived(IToolchain toolchain, Type benchmarkType, Dictionary
413
414
414
415
foreach ( var benchmarkSurvivedValidator in benchmarkSurvivedValidators )
415
416
{
417
+ // CoreRT is missing some of the CoreCLR threading/task related perf improvements, so sizeof(Task<int>) calculated for CoreCLR < sizeof(Task<int>) on CoreRT
418
+ // see https://github.com/dotnet/corert/issues/5705
419
+ if ( benchmarkSurvivedValidator . Key == nameof ( AccurateSurvived . AllocateTaskSurvive ) && toolchain is CoreRtToolchain )
420
+ continue ;
421
+
416
422
var survivedBenchmarks = benchmarks . BenchmarksCases . Where ( benchmark => benchmark . Descriptor . WorkloadMethodDisplayInfo == benchmarkSurvivedValidator . Key ) . ToArray ( ) ;
417
423
418
424
foreach ( var benchmark in survivedBenchmarks )
0 commit comments