From d0f5e65015dd59cdd566fa934a3f87541d667509 Mon Sep 17 00:00:00 2001 From: Roman Spring Date: Tue, 2 Dec 2025 07:23:36 +0100 Subject: [PATCH] feat: Add time tracking --- AdventOfCode2026/Day1.cs | 1 + AdventOfCode2026/Program.cs | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/AdventOfCode2026/Day1.cs b/AdventOfCode2026/Day1.cs index c43baca..7df5691 100644 --- a/AdventOfCode2026/Day1.cs +++ b/AdventOfCode2026/Day1.cs @@ -3,6 +3,7 @@ namespace AdventOfCode2026; public sealed class Day1 : Solution { private const int MaxArrow = 100; + public override string SolvePart1() { var arrow = 50; diff --git a/AdventOfCode2026/Program.cs b/AdventOfCode2026/Program.cs index 1819e61..c105c0d 100644 --- a/AdventOfCode2026/Program.cs +++ b/AdventOfCode2026/Program.cs @@ -7,10 +7,14 @@ internal class Program const int numberOfDays = 12; foreach (var day in Enumerable.Range(1, numberOfDays)) { + var startTime = DateTime.Now; RunDay(day); + var endTime = DateTime.Now; + var duration = endTime - startTime; + Console.WriteLine($"\tTime taken: {duration.TotalMilliseconds} ms"); } } - + private static void RunDay(int day) { var solutionText = $"Solution for Day {day.ToString().PadLeft(2, '0')}:"; @@ -21,14 +25,24 @@ internal class Program Console.WriteLine($"{solutionText} is not implemented."); return; } + var instance = Activator.CreateInstance(classType); if (instance is not Solution solution) { throw new NotImplementedException($"{classType} is not implemented."); } - + Console.WriteLine($"{solutionText}"); - Console.WriteLine($"\tPart 1: {solution.SolvePart1()}"); - Console.WriteLine($"\tPart 2: {solution.SolvePart2()}"); + var startPart1 = DateTime.Now; + var solution1 = solution.SolvePart1(); + var endPart1 = DateTime.Now; + var durationPart1 = endPart1 - startPart1; + Console.WriteLine($"\tPart 1 ({durationPart1.TotalMilliseconds} ms): {solution1} "); + + var startPart2 = DateTime.Now; + var solution2 = solution.SolvePart2(); + var endPart2 = DateTime.Now; + var durationPart2 = endPart2 - startPart2; + Console.WriteLine($"\tPart 2 ({durationPart2.TotalMilliseconds} ms): {solution2} "); } } \ No newline at end of file