feat: Add time tracking

This commit is contained in:
Roman Spring 2025-12-02 07:23:36 +01:00
parent 8e8ca67091
commit d0f5e65015
2 changed files with 19 additions and 4 deletions

View file

@ -3,6 +3,7 @@ namespace AdventOfCode2026;
public sealed class Day1 : Solution
{
private const int MaxArrow = 100;
public override string SolvePart1()
{
var arrow = 50;

View file

@ -7,7 +7,11 @@ 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");
}
}
@ -21,6 +25,7 @@ internal class Program
Console.WriteLine($"{solutionText} is not implemented.");
return;
}
var instance = Activator.CreateInstance(classType);
if (instance is not Solution solution)
{
@ -28,7 +33,16 @@ internal class Program
}
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} ");
}
}