From 4d2257a5af7fd9bf3d2e9d68c18ac73cc720f7db Mon Sep 17 00:00:00 2001
From: "Mohammad A.Mohadjer" <m.mohadjer@mabnadp.com>
Date: Tue, 23 Apr 2024 15:30:44 +0330
Subject: [PATCH] Skip rounding of duration milliseconds.

---
 src/MiniProfiler.Shared/CustomTiming.cs |  2 +-
 src/MiniProfiler.Shared/MiniProfiler.cs | 13 ++++++-------
 src/MiniProfiler.Shared/Timing.cs       |  2 +-
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/MiniProfiler.Shared/CustomTiming.cs b/src/MiniProfiler.Shared/CustomTiming.cs
index d305ad83..eb1fa126 100644
--- a/src/MiniProfiler.Shared/CustomTiming.cs
+++ b/src/MiniProfiler.Shared/CustomTiming.cs
@@ -37,7 +37,7 @@ public CustomTiming(MiniProfiler profiler, string commandString, decimal? minSav
             CommandString = commandString;
 
             Id = Guid.NewGuid();
-            StartMilliseconds = profiler.GetRoundedMilliseconds(profiler.ElapsedTicks);
+            StartMilliseconds = profiler.GetMilliseconds(profiler.ElapsedTicks);
 
             if (includeStackTrace && !profiler.Options.ExcludeStackTraceSnippetFromCustomTimings)
             {
diff --git a/src/MiniProfiler.Shared/MiniProfiler.cs b/src/MiniProfiler.Shared/MiniProfiler.cs
index f5468a8b..f7f2f7bc 100644
--- a/src/MiniProfiler.Shared/MiniProfiler.cs
+++ b/src/MiniProfiler.Shared/MiniProfiler.cs
@@ -282,7 +282,7 @@ private bool InnerStop()
             }
 
             Stopwatch.Stop();
-            DurationMilliseconds = GetRoundedMilliseconds(ElapsedTicks);
+            DurationMilliseconds = GetMilliseconds(ElapsedTicks);
 
             foreach (var timing in GetTimingHierarchy())
             {
@@ -366,13 +366,12 @@ internal Timing StepImpl(string? name, decimal? minSaveMs = null, bool? includeC
             new Timing(this, Head, name, minSaveMs, includeChildrenWithMinSave);
 
         /// <summary>
-        /// Returns milliseconds based on Stopwatch's Frequency, rounded to two decimal places.
+        /// Returns milliseconds based on Stopwatch's Frequency.
         /// </summary>
-        /// <param name="ticks">The tick count to round.</param>
-        internal decimal GetRoundedMilliseconds(long ticks)
+        /// <param name="ticks">The tick count.</param>
+        internal decimal GetMilliseconds(long ticks)
         {
-            long times100 = ticks * 100000 / Stopwatch.Frequency;
-            return times100 / 100m;
+            return ticks * 1000M / Stopwatch.Frequency;
         }
 
         /// <summary>
@@ -380,6 +379,6 @@ internal decimal GetRoundedMilliseconds(long ticks)
         /// </summary>
         /// <param name="startTicks">The start tick count.</param>
         internal decimal GetDurationMilliseconds(long startTicks) =>
-            GetRoundedMilliseconds(ElapsedTicks - startTicks);
+            GetMilliseconds(ElapsedTicks - startTicks);
     }
 }
diff --git a/src/MiniProfiler.Shared/Timing.cs b/src/MiniProfiler.Shared/Timing.cs
index 87404bb6..7a03a364 100644
--- a/src/MiniProfiler.Shared/Timing.cs
+++ b/src/MiniProfiler.Shared/Timing.cs
@@ -73,7 +73,7 @@ public Timing(MiniProfiler profiler, Timing? parent, string? name, decimal? minS
             _startTicks = profiler.ElapsedTicks;
             _minSaveMs = minSaveMs;
             _includeChildrenWithMinSave = includeChildrenWithMinSave == true;
-            StartMilliseconds = profiler.GetRoundedMilliseconds(_startTicks);
+            StartMilliseconds = profiler.GetMilliseconds(_startTicks);
 
             if (profiler.Options.EnableDebugMode)
             {