Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to hide Gen X columns #1764

Merged
merged 5 commits into from Aug 4, 2021
Merged

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Aug 3, 2021

Some of our users, are not interested in the Gen 0/1/2 columns, all they want to see is the Allocated column.

Example:

public class AccurateAllocations
{
    [Benchmark] public byte[] EightBytesArray() => new byte[8];
    [Benchmark] public byte[] SixtyFourBytesArray() => new byte[64];
    [Benchmark] public Task<int> AllocateTask() => Task.FromResult(default(int));
}

Before:

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
EightBytesArray 4.245 ns 0.0804 ns 0.0671 ns 0.0041 - - 32 B
SixtyFourBytesArray 8.160 ns 0.1413 ns 0.1180 ns 0.0112 - - 88 B
AllocateTask 7.561 ns 0.1613 ns 0.1430 ns 0.0092 - - 72 B

First commit (don't display Gen X collumn if there was no collections in Gen X):

Method Mean Error StdDev Gen 0 Allocated
EightBytesArray 4.184 ns 0.0623 ns 0.0552 ns 0.0041 32 B
SixtyFourBytesArray 8.255 ns 0.2031 ns 0.1801 ns 0.0112 88 B
AllocateTask 7.996 ns 0.1210 ns 0.1073 ns 0.0092 72 B
[MemoryDiagnoser(displayGenColumns: false)]
Method Mean Error StdDev Allocated
EightBytesArray 4.546 ns 0.1317 ns 0.1232 ns 32 B
SixtyFourBytesArray 8.713 ns 0.2251 ns 0.1995 ns 88 B
AllocateTask 8.324 ns 0.1991 ns 0.2213 ns 72 B

cc @stephentoub

Copy link
Member

@AndreyAkinshin AndreyAkinshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we have some problems with the column order. Let's consider the following benchmark class:

[MemoryDiagnoser]
public class ColumnOrder
{
    [Benchmark] public byte[] A() => new byte[8];

    [Benchmark]
    public void B()
    {
        byte[] b = new byte[8];
        GC.Collect();
    }
}

It gives a summary table like this one:

| Method |          Mean |          Error |        StdDev |     Gen 0 | Allocated |     Gen 1 |     Gen 2 |
|------- |--------------:|---------------:|--------------:|----------:|----------:|----------:|----------:|
|      A |      2.720 ns |      0.6458 ns |     0.0354 ns |    0.0077 |      32 B |         - |         - |
|      B | 64,272.705 ns | 28,250.1984 ns | 1,548.4887 ns | 1000.0000 |      32 B | 1000.0000 | 1000.0000 |

As you can see, now we have the Allocated column between Gen 0 and Gen 1.

@adamsitnik
Copy link
Member Author

@AndreyAkinshin great catch! I've fixed that in 51d39f0

Copy link
Member

@AndreyAkinshin AndreyAkinshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamsitnik now it works great, thanks!

@adamsitnik adamsitnik merged commit f372668 into master Aug 4, 2021
@adamsitnik adamsitnik deleted the memoryDiagnoserFewerColumns branch August 4, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants