feat: Add time tracking
This commit is contained in:
parent
8e8ca67091
commit
d0f5e65015
2 changed files with 19 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ namespace AdventOfCode2026;
|
||||||
public sealed class Day1 : Solution
|
public sealed class Day1 : Solution
|
||||||
{
|
{
|
||||||
private const int MaxArrow = 100;
|
private const int MaxArrow = 100;
|
||||||
|
|
||||||
public override string SolvePart1()
|
public override string SolvePart1()
|
||||||
{
|
{
|
||||||
var arrow = 50;
|
var arrow = 50;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ internal class Program
|
||||||
const int numberOfDays = 12;
|
const int numberOfDays = 12;
|
||||||
foreach (var day in Enumerable.Range(1, numberOfDays))
|
foreach (var day in Enumerable.Range(1, numberOfDays))
|
||||||
{
|
{
|
||||||
|
var startTime = DateTime.Now;
|
||||||
RunDay(day);
|
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.");
|
Console.WriteLine($"{solutionText} is not implemented.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance = Activator.CreateInstance(classType);
|
var instance = Activator.CreateInstance(classType);
|
||||||
if (instance is not Solution solution)
|
if (instance is not Solution solution)
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +33,16 @@ internal class Program
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"{solutionText}");
|
Console.WriteLine($"{solutionText}");
|
||||||
Console.WriteLine($"\tPart 1: {solution.SolvePart1()}");
|
var startPart1 = DateTime.Now;
|
||||||
Console.WriteLine($"\tPart 2: {solution.SolvePart2()}");
|
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} ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue