From 26bf9cd7ec2500327e845a12114faf2fc9e9edc9 Mon Sep 17 00:00:00 2001 From: Xander Sigler Date: Sat, 9 Dec 2023 20:54:34 -0800 Subject: [PATCH] Fixed runtime resolution and parsing --- AdventOfCode/Models/AOCDay.cs | 3 +++ AdventOfCode/Models/AOCResponse.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/AdventOfCode/Models/AOCDay.cs b/AdventOfCode/Models/AOCDay.cs index 9a7f7ab..da90194 100644 --- a/AdventOfCode/Models/AOCDay.cs +++ b/AdventOfCode/Models/AOCDay.cs @@ -39,6 +39,9 @@ namespace AdventOfCode.Models break; } timer.Stop(); + Console.WriteLine($"Elapsed ticks is {timer.ElapsedTicks.ToString()}"); + Console.WriteLine($"System Clock Resolution: {TimeSpan.FromTicks(Stopwatch.Frequency).TotalSeconds} seconds"); + Console.WriteLine($"Local Time Zone: {TimeZoneInfo.Local}"); this._response.RunTime = timer.ElapsedTicks.ToString(); this._response.Status = true; } diff --git a/AdventOfCode/Models/AOCResponse.cs b/AdventOfCode/Models/AOCResponse.cs index bcdf6f8..8a971f4 100644 --- a/AdventOfCode/Models/AOCResponse.cs +++ b/AdventOfCode/Models/AOCResponse.cs @@ -25,7 +25,7 @@ namespace AdventOfCode.Models public string FormatRunTime() { - var ts = TimeSpan.FromTicks((long)Convert.ToDouble(timeInTicks)); + var ts = TimeSpan.FromTicks(long.Parse(timeInTicks)); var microseconds = (ts.Ticks - (ts.Milliseconds * TimeSpan.TicksPerMillisecond)) / (TimeSpan.TicksPerMillisecond / 1000); return $"Run time is {ts.Minutes}min {ts.Seconds}sec {ts.Milliseconds}ms {microseconds}µs"; }