-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BenchmarkSwitcher used instead of self-baken solution
- Loading branch information
Showing
2 changed files
with
3 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,13 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Reflection; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace gfoidl.Stochastics.Benchmarks | ||
{ | ||
static class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
Console.WriteLine("one and only arg has to be name of benchmark"); | ||
PrintAvailableBenchmarks(); | ||
Environment.Exit(1); | ||
} | ||
|
||
Console.WriteLine($"{nameof(Vector.IsHardwareAccelerated)}: {Vector.IsHardwareAccelerated}"); | ||
|
||
string type = args[0]; | ||
IBenchmark benchmark = GetBenchmark(type); | ||
|
||
if (benchmark == null) | ||
{ | ||
Console.WriteLine($"unknown benchmark '{type}'"); | ||
PrintAvailableBenchmarks(); | ||
Environment.Exit(2); | ||
} | ||
|
||
benchmark.Run(); | ||
|
||
if (Debugger.IsAttached) | ||
{ | ||
Console.WriteLine("\nEnd."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
//--------------------------------------------------------------------- | ||
private static IBenchmark GetBenchmark(string type) | ||
{ | ||
Assembly assembly = typeof(Program).Assembly; | ||
|
||
Type benchmarkType = assembly | ||
.DefinedTypes | ||
.FirstOrDefault(t => typeof(IBenchmark).IsAssignableFrom(t) && t.Name == type); | ||
|
||
if (benchmarkType == null) return null; | ||
|
||
return Activator.CreateInstance(benchmarkType) as IBenchmark; | ||
} | ||
//--------------------------------------------------------------------- | ||
private static void PrintAvailableBenchmarks() | ||
{ | ||
Assembly assembly = typeof(Program).Assembly; | ||
|
||
var types = assembly | ||
.DefinedTypes | ||
.Where(t => typeof(IBenchmark).IsAssignableFrom(t) && t != typeof(IBenchmark)) | ||
.OrderBy(t => t.Name); | ||
|
||
Console.WriteLine("\nAvailable benchmarks:"); | ||
foreach (Type type in types) | ||
Console.WriteLine($"\t{type.Name}"); | ||
var switcher = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly); | ||
switcher.Run(args); | ||
} | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
perf/gfoidl.Stochastics.Benchmarks/Properties/launchSettings.json
This file was deleted.
Oops, something went wrong.