Skip to content

Commit

Permalink
Remove unnecessary settings
Browse files Browse the repository at this point in the history
  • Loading branch information
si618 committed Mar 11, 2024
1 parent 5787f88 commit d61b6c9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Benchmarks.App/BenchmarkRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static IEnumerable<Summary> RunAndBuildSummaries()
}


public static IEnumerable<Summary> RunAndBuildSummaries(ListSettings settings)
public static IEnumerable<Summary> RunAndBuildSummaries(BenchmarkSettings settings)
{
var args = settings.BuildArgs();
var type = Reflection.GetBenchmarkTypes().First(type => type.Name == settings.Name);
Expand Down
4 changes: 2 additions & 2 deletions Benchmarks.App/Commands/BenchmarkCommand.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Benchmarks.App.Commands;

internal sealed class BenchmarkCommand : Command<ListSettings>
internal sealed class BenchmarkCommand : Command<BenchmarkSettings>
{
[SuppressMessage("ReSharper", "RedundantNullableFlowAttribute")]
public override int Execute(
[NotNull] CommandContext context,
[NotNull] ListSettings settings)
[NotNull] BenchmarkSettings settings)
{
if (BenchmarkRunner.IsDebugConfiguration(settings.Debug))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Benchmarks.App.Commands;

internal sealed class ListSettings : CommandSettings
internal sealed class BenchmarkSettings : CommandSettings
{
[Description("Benchmark name")]
[CommandArgument(0, "[filter]")]
Expand All @@ -10,10 +10,6 @@ internal sealed class ListSettings : CommandSettings
[CommandOption("--debug")]
public bool Debug { get; init; }

[Description("BenchmarkDotNet Exporters: GitHub/StackOverflow/RPlot/CSV/JSON/HTML/XML")]
[CommandOption("--exporters")]
public string? Exporters { get; init; }

public override ValidationResult Validate()
{
if (!Reflection.GetBenchmarkTypes().Any(type => type.Name == Name))
Expand All @@ -24,16 +20,5 @@ public override ValidationResult Validate()
return ValidationResult.Success();
}

public string[] BuildArgs()
{
var args = new List<string> { "--filter", $"*{Name}*" };

if (!string.IsNullOrEmpty(Exporters))
{
args.Add("--exporters");
args.Add(Exporters);
}

return [.. args];
}
public string[] BuildArgs() => ["--filter", $"*{Name}*"];
}
4 changes: 2 additions & 2 deletions Benchmarks.App/Commands/InfoCommand.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Benchmarks.App.Commands;

internal sealed class InfoCommand : Command<BenchmarkRunSettings>
internal sealed class InfoCommand : Command<BenchmarkSettings>
{
[SuppressMessage("ReSharper", "RedundantNullableFlowAttribute")]
public override int Execute(
[NotNull] CommandContext context,
[NotNull] BenchmarkRunSettings settings)
[NotNull] BenchmarkSettings settings)
{
ConsoleWriter.WriteHeader();

Expand Down
23 changes: 0 additions & 23 deletions Benchmarks.App/Commands/RunSettings.cs

This file was deleted.

7 changes: 5 additions & 2 deletions Benchmarks.App/Commands/WorkflowCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ internal sealed class WorkflowCommand : Command
[SuppressMessage("ReSharper", "RedundantNullableFlowAttribute")]
public override int Execute([NotNull] CommandContext context)
{
ConsoleWriter.WriteHeader();

if (BenchmarkRunner.IsDebugConfiguration(true))
{
return 1;
}

var settings = new ListSettings { Exporters = "json" };
// Exporters: GitHub/StackOverflow/RPlot/CSV/JSON/HTML/XML")]
var args = new[] { "--filter", $"Benchmarks*", "--exporters", "json" };

BenchmarkRunner.RunBenchmarks(Reflection.GetBenchmarkTypes().ToArray(), settings.BuildArgs());
BenchmarkRunner.RunBenchmarks([.. Reflection.GetBenchmarkTypes()], args);

CombineBenchmarkResults();

Expand Down
2 changes: 1 addition & 1 deletion Benchmarks.App/Menus/Selections/RunSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override int Execute()
return 1;
}

var settings = new ListSettings { Name = Benchmark.Name };
var settings = new BenchmarkSettings { Name = Benchmark.Name };
var summaries = BenchmarkRunner.RunAndBuildSummaries(settings);
var builder = new SpectreReportBuilder(summaries);
var report = builder.Build();
Expand Down

0 comments on commit d61b6c9

Please sign in to comment.