Skip to content

Commit

Permalink
Added option to list all benchmarks (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
L3tum authored Sep 4, 2019
1 parent e4e6b5b commit 25a4a63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Benchmarker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private static void Main(string[] args)
var options = new Options();

#if RELEASE
Parser.Default.ParseArguments<Options>(args).WithParsed<Options>(opts =>
Parser.Default.ParseArguments<Options>(args).WithParsed(opts =>
{
options = opts;

Expand All @@ -42,6 +42,11 @@ private static void Main(string[] args)
}
});

if (options.ListBenchmarks)
{
Console.WriteLine(string.Join(", ", BenchmarkRunner.AvailableBenchmarks));
}

if (options?.Benchmark == null)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions Benchmarking.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Dockerfile.alpine = Dockerfile.alpine
Dockerfile.arm32v7 = Dockerfile.arm32v7
Dockerfile.arm64 = Dockerfile.arm64
.github\workflows\label-manager.yml = .github\workflows\label-manager.yml
.github\labels.json = .github\labels.json
.github\workflows\netcore.yml = .github\workflows\netcore.yml
Readme.md = Readme.md
.github\workflows\secrets-checker.yml = .github\workflows\secrets-checker.yml
EndProjectSection
EndProject
Global
Expand Down
9 changes: 6 additions & 3 deletions Benchmarking/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ public class Options
[Option('t', "threads", Required = false, Default = 0, HelpText = "Manually set the number of threads to use (overrides multithreaded)")]
public int Threads { get; set; } = 1;

[Option('r', "runs", Required = false, HelpText = "Times to run the benchmark and average the result")]
[Option('r', "runs", Default = 3, HelpText = "Times to run the benchmark and average the result")]
public int Runs { get; set; } = 3;

[Option('m', "multithreaded", Required = false, HelpText = "Run benchmarks multithreaded (automatically uses all logical processors)")]
[Option('m', "multithreaded", Default = false, HelpText = "Run benchmarks multithreaded (automatically uses all logical processors)")]
public bool Multithreaded { get; set; } = false;

[Option('b', "benchmark", Required = true, HelpText = "Choose the benchmark to run")]
[Option('b', "benchmark", HelpText = "Choose the benchmark to run")]
public string Benchmark { get; set; }

[Option('l', "list-benchmarks", Default = false, HelpText = "List available benchmarks")]
public bool ListBenchmarks { get; set; }
}
}

0 comments on commit 25a4a63

Please sign in to comment.