Skip to content

Conversation

adamsitnik
Copy link
Member

fixes #730

Example:

public class FileSample
{
    private readonly string filePath = Path.GetTempFileName();

    [IterationSetup]
    public void Create()
    {
        using (File.Create(filePath)) { }
    }

    [Benchmark]
    public void Remove() => File.Delete(filePath);
}

/cc @stephentoub @nietras

…re not, run benchmark once per iteration to avoid user confusion, fixes #730
@adamsitnik
Copy link
Member Author

@AndreyAkinshin The histogram for my example looks really nice!

-------------------- Histogram --------------------
[0.979 ms ; 1.701 ms) | @@@
[1.701 ms ; 2.227 ms) | @@@@
[2.227 ms ; 2.573 ms) |
[2.573 ms ; 3.064 ms) | @@@@@@@@@@@@@
[3.064 ms ; 3.590 ms) | @@@@@@@@@@@@@@@@@@@@@@@@
[3.590 ms ; 4.186 ms) | @@@@@@
[4.186 ms ; 4.776 ms) | @@@@
[4.776 ms ; 5.470 ms) | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
[5.470 ms ; 5.989 ms) | @@@@@
[5.989 ms ; 6.424 ms) | @@
[6.424 ms ; 6.689 ms) |
[6.689 ms ; 7.215 ms) | @@@@
[7.215 ms ; 7.826 ms) | @
---------------------------------------------------

And I got nice multimodal warning:

MultimodalDistribution
  FileSample.Remove: InvocationCount=1, UnrollFactor=1 -> It seems that the distribution is bimodal (mValue = 3,86666666666667)

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.

LGTM

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.

IterationSetup is not running before each benchmark invocation
2 participants