Skip to content

Commit

Permalink
Added TaskNoAllocate in MemoryDiagnoserSurvivedIsAccurate test.
Browse files Browse the repository at this point in the history
  • Loading branch information
timcassell committed Jan 24, 2021
1 parent 32aecbb commit b3f2aaf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ public class AccurateSurvived
public byte[] bytes64;
public Task<int> task;

[GlobalSetup(Targets = new string[] { nameof(EightBytesArrayNoAllocate), nameof(SixtyFourBytesArrayNoAllocate) })]
[GlobalSetup(Targets = new string[] { nameof(EightBytesArrayNoAllocate), nameof(SixtyFourBytesArrayNoAllocate), nameof(TaskNoAllocate) })]
public void SetupNoAllocate()
{
bytes8 = new byte[8];
bytes64 = new byte[64];
task = Task.FromResult(default(int));
}

[Benchmark] public byte[] EightBytesArrayNoAllocate() => bytes8;
[Benchmark] public byte[] SixtyFourBytesArrayNoAllocate() => bytes64;
[Benchmark] public Task<int> TaskNoAllocate() => task;


[Benchmark] public void EightBytesArraySurvive() => bytes8 = new byte[8];
Expand Down Expand Up @@ -118,6 +120,7 @@ public void MemoryDiagnoserSurvivedIsAccurate(IToolchain toolchain)

{ nameof(AccurateSurvived.EightBytesArrayNoAllocate), 0 },
{ nameof(AccurateSurvived.SixtyFourBytesArrayNoAllocate), 0 },
{ nameof(AccurateSurvived.TaskNoAllocate), 0 },

{ nameof(AccurateSurvived.EightBytesArraySurvive), 8 + objectAllocationOverhead + arraySizeOverhead },
{ nameof(AccurateSurvived.SixtyFourBytesArraySurvive), 64 + objectAllocationOverhead + arraySizeOverhead },
Expand Down

0 comments on commit b3f2aaf

Please sign in to comment.