Add benchmark support using -b
This commit is contained in:
13
Program.cs
13
Program.cs
@@ -1,9 +1,18 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using AdventOfCode;
|
||||
using AdventOfCode.Days;
|
||||
using BenchmarkDotNet.Running;
|
||||
using Spectre.Console;
|
||||
|
||||
// Benchmark
|
||||
if (args is ["--bench" or "-b"])
|
||||
{
|
||||
BenchmarkRunner.Run<DayBenchmark>();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
// Normal run
|
||||
var days = Assembly.GetAssembly(typeof(Day))!.GetTypes()
|
||||
.Where(t => t.IsAssignableTo(typeof(Day)) && t.GetConstructor(Type.EmptyTypes) != null && !t.IsAbstract)
|
||||
.Select(t => (Day)Activator.CreateInstance(t)!);
|
||||
|
||||
Reference in New Issue
Block a user