Skip to content

passed args to benchmark runner #1292

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

Merged
merged 19 commits into from
Jan 29, 2021
Merged

passed args to benchmark runner #1292

merged 19 commits into from
Jan 29, 2021

Conversation

chan18
Copy link
Contributor

@chan18 chan18 commented Oct 24, 2019

fixes #1290

@dnfclas
Copy link

dnfclas commented Oct 24, 2019

CLA assistant check
All CLA requirements met.

@chan18
Copy link
Contributor Author

chan18 commented Oct 24, 2019

did not wrote test cases yet, need a review from @adamsitnik,

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.

Thank you @chan18 ! The PR looks very promising, please take a look at my comments and address them.

@chan18
Copy link
Contributor Author

chan18 commented Nov 2, 2019

@adamsitnik

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.

Looks good to me!

Could you please add the public static Summary[] Run(Assembly assembly, IConfig config = null,string[] args = null) overload and fix the formatting issues?

@chan18
Copy link
Contributor Author

chan18 commented Nov 5, 2019

var logger = config.GetNonNullCompositeLogger();
var userInteraction = new UserInteraction();
var (isParsingSuccess, parsedConfig, options) = ConfigParser.Parse(args, logger, config);
if (!isParsingSuccess) // invalid console args, the ConfigParser printed the error
return null;
if (options.PrintInformation)
{
logger.WriteLine(HostEnvironmentInfo.GetInformation());
return null;
}
var effectiveConfig = ManualConfig.Union(config, parsedConfig);
var types = new List<Type>();
types.Add(type);
var (allTypesValid, allAvailableTypesWithRunnableBenchmarks) = TypeFilter.GetTypesWithRunnableBenchmarks(types, new List<Assembly>(), logger);
if (!allTypesValid) // there were some invalid and TypeFilter printed errors
return null;
if (allAvailableTypesWithRunnableBenchmarks.IsEmpty())
{
userInteraction.PrintNoBenchmarksError(logger);
return null;
}
if (options.ListBenchmarkCaseMode != ListBenchmarkCaseMode.Disabled)
{
BenchmarkCasesPrinter.PrintList(logger, effectiveConfig, allAvailableTypesWithRunnableBenchmarks, options);
return null;
}
var benchmarks = options.UserProvidedFilters
? TypeFilter.Filter(effectiveConfig, allAvailableTypesWithRunnableBenchmarks)
: new BenchmarkRunInfo[] { BenchmarkConverter.TypeToBenchmarks(type, config) };
return BenchmarkRunnerClean.Run(benchmarks).Single();

needs another overload. I am thinking to create another function to move the code that parses args and use it in two different functions, Something like this in below.

RunWithDirtyAssemblyResolveHelper(Type type, IConfig config, string[] args)
RunWithDirtyAssemblyResolveHelper(Assembly assembly, IConfig config = null,string[] args) 

@adamsitnik

… types, IEnumerable<Assembly> assemblies, IConfig config, string[] args)
@chan18
Copy link
Contributor Author

chan18 commented Dec 11, 2019

hi, @adamsitnik please review it. Let me know any other changes or improvements you want to make!

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.

Hi @chan18

Thank you for your hard work! Please take a look at my comments.

Adam

@adamsitnik
Copy link
Member

The build fails with following compilation error:

Running/BenchmarkRunnerDirty.cs(88,16): error CS0029: Cannot implicitly convert type 'BenchmarkDotNet.Reports.Summary[]' to 'BenchmarkDotNet.Reports.Summary'

Could you please fix it?

@chan18
Copy link
Contributor Author

chan18 commented Feb 3, 2020

Fixed it, Can you please check. let me know if you have anyother change that i need to make.

fixed compiled error.
# Conflicts:
#	src/BenchmarkDotNet/Running/BenchmarkSwitcher.cs
@adamsitnik adamsitnik merged commit 6a151fe into dotnet:master Jan 29, 2021
@adamsitnik adamsitnik added this to the v0.13.0 milestone Jan 29, 2021
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.

BenchmarkRunner should support parsing console line arguments
3 participants