Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip rounding of duration milliseconds. #670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MiniProfiler.Shared/CustomTiming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 6 additions & 7 deletions src/MiniProfiler.Shared/MiniProfiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private bool InnerStop()
}

Stopwatch.Stop();
DurationMilliseconds = GetRoundedMilliseconds(ElapsedTicks);
DurationMilliseconds = GetMilliseconds(ElapsedTicks);

foreach (var timing in GetTimingHierarchy())
{
Expand Down Expand Up @@ -366,20 +366,19 @@ 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>
/// Returns how many milliseconds have elapsed since <paramref name="startTicks"/> was recorded.
/// </summary>
/// <param name="startTicks">The start tick count.</param>
internal decimal GetDurationMilliseconds(long startTicks) =>
GetRoundedMilliseconds(ElapsedTicks - startTicks);
GetMilliseconds(ElapsedTicks - startTicks);
}
}
2 changes: 1 addition & 1 deletion src/MiniProfiler.Shared/Timing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down