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

Implement --list - fixes #905 #914

Merged
merged 5 commits into from
Oct 16, 2018
Merged

Conversation

WojciechNagorski
Copy link
Contributor

@WojciechNagorski WojciechNagorski commented Oct 16, 2018

Fix for #905

I've implemented '--list:[flat|tree]'.

Now you should be able to run BenchmarkDotNet.Samples.exe with options:

BenchmarkDotNet.Samples.exe --list flat

BenchmarkDotNet.Samples.Algo_Md5VsSha256.Md5
BenchmarkDotNet.Samples.Algo_Md5VsSha256.Sha256
BenchmarkDotNet.Samples.IntroArguments.Benchmark
BenchmarkDotNet.Samples.IntroArgumentsSource.SingleArgument
BenchmarkDotNet.Samples.IntroArgumentsSource.ManyArguments
BenchmarkDotNet.Samples.IntroArrayParam.ArrayIndexOf
BenchmarkDotNet.Samples.IntroArrayParam.ManualIndexOf
BenchmarkDotNet.Samples.IntroBasic.Sleep
BenchmarkDotNet.Samples.IntroBasic.Thread.Sleep(10)
[...]

BenchmarkDotNet.Samples.exe --list tree

BenchmarkDotNet
 └─Samples
    ├─Algo_Md5VsSha256
    │  ├─Md5
    │  └─Sha256
    ├─IntroArguments
    │  └─Benchmark
    ├─IntroArgumentsSource
    │  ├─SingleArgument
    │  └─ManyArguments
    ├─IntroArrayParam
    │  ├─ArrayIndexOf
    │  └─ManualIndexOf
    ├─IntroBasic
    │  ├─Sleep
    │  └─Thread
    │     └─Sleep(10)
[...]

You can also use filter option, like this:

BenchmarkDotNet.Samples.exe --list flat --filter *IntroSetupCleanup*

BenchmarkDotNet.Samples.IntroSetupCleanupGlobal.Logic
BenchmarkDotNet.Samples.IntroSetupCleanupIteration.Benchmark
BenchmarkDotNet.Samples.IntroSetupCleanupTarget.BenchmarkA
BenchmarkDotNet.Samples.IntroSetupCleanupTarget.BenchmarkB
BenchmarkDotNet.Samples.IntroSetupCleanupTarget.BenchmarkC
BenchmarkDotNet.Samples.IntroSetupCleanupTarget.BenchmarkD

BenchmarkDotNet.Samples.exe --list tree --filter *IntroSetupCleanup*

BenchmarkDotNet
 └─Samples
    ├─IntroSetupCleanupGlobal
    │  └─Logic
    ├─IntroSetupCleanupIteration
    │  └─Benchmark
    └─IntroSetupCleanupTarget
       ├─BenchmarkA
       ├─BenchmarkB
       ├─BenchmarkC
       └─BenchmarkD

@dnfclas
Copy link

dnfclas commented Oct 16, 2018

CLA assistant check
All CLA requirements met.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@wojtpl2 Great implementation of a really good idea! I can't wait to merge this PR!

I added some comments, mostly very minor things. Could you please fix them?

using System;

namespace BenchmarkDotNet.ListBenchmarks {

This comment was marked as spam.


PrintNode(node, indent);
}

This comment was marked as spam.


void PrintChildNode(Node node, string indent, bool isLast)
{
// Print the provided pipes/spaces indent

This comment was marked as spam.

private readonly IBenchmarkCasesPrinter printer;

public BenchmarkCasesPrinter(ListBenchmarkCaseMode listBenchmarkCaseMode)
{

This comment was marked as spam.

{
internal interface IBenchmarkCasesPrinter
{
void Print(IEnumerable<string> testName);

This comment was marked as spam.

}

public void Print(IEnumerable<string> testName)
{

This comment was marked as spam.

using System.Collections.Generic;
using System.Linq;

namespace BenchmarkDotNet.ListBenchmarks {

This comment was marked as spam.

PrepareNodeTree(topLevelNodes, partsOfName);
}

var tree = new AsciiTreeDiagram();

This comment was marked as spam.

if (listBenchmarkCase)
{
var testName = filteredBenchmarks.SelectMany(p => p.BenchmarksCases)
.Select(p => p.Descriptor.Type.Namespace + "." + p.Descriptor.DisplayInfo).Distinct();

This comment was marked as spam.

@@ -0,0 +1,51 @@
using System;

namespace BenchmarkDotNet.ListBenchmarks {

This comment was marked as spam.

@WojciechNagorski
Copy link
Contributor Author

Yes, great suggestions. I'll fix it.

@WojciechNagorski
Copy link
Contributor Author

Now everything is fixed.

@adamsitnik adamsitnik merged commit 330f66c into dotnet:master Oct 16, 2018
@adamsitnik
Copy link
Member

@wojtpl2 thank you! awesome PR!

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

4 participants