Add benchmark support using -b

This commit is contained in:
2022-12-17 21:48:16 +01:00
parent 147c348ee1
commit 63c866f5a0
20 changed files with 469 additions and 341 deletions

View File

@@ -121,7 +121,7 @@ public class Day14 : Day
private readonly Point _sandSource = new(500, 0);
private Point _offsetSandSource;
public override void RunPart1()
public override void RunPart1(bool display = true)
{
var map = GenerateMap();
@@ -136,12 +136,15 @@ public class Day14 : Day
sandBlocksCount++;
}
AnsiConsole.Write(canvas);
if (display)
{
AnsiConsole.Write(canvas);
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
}
}
public override void RunPart2()
public override void RunPart2(bool display = true)
{
var map = GenerateDictionaryMap();
@@ -156,9 +159,13 @@ public class Day14 : Day
sandBlocksCount++;
}
AnsiConsole.Write(GenerateCanvas(map, _sandSource));
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
if (display)
{
AnsiConsole.Write(GenerateCanvas(map, _sandSource));
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
}
}
private static bool GenerateSand(CellType[,] map, Canvas canvas, in Point sandSource)