-
Notifications
You must be signed in to change notification settings - Fork 610
Closed
Description
The durations reported by MiniProfiler when run on Linux are 100x larger than they should be.
This is caused by the change here which was released as 4.2.43.
Stopwatch ticks are not the same as DateTime or TimeSpan ticks (because that's not going to confuse anyone 🙄) so using TimeSpan.TicksPerMillisecond to convert is not reliable. Previous versions of MiniProfiler correctly used Stopwatch.Frequency to account for this. See this doc page for an explanation: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.elapsedticks?view=net-6.0#remarks
Simple example comparing Ubuntu & Windows output:
using StackExchange.Profiling;
using System.Diagnostics;
var stopwatch = Stopwatch.StartNew();
Thread.Sleep(1000);
stopwatch.Stop();
Console.WriteLine(@$"Running under: {System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier}
Stopwatch:
ElapsedTicks: {stopwatch.ElapsedTicks}
ElapsedMilliseconds: {stopwatch.ElapsedMilliseconds}
TimeSpan.TicksPerMillisecond: {TimeSpan.TicksPerMillisecond}");
var profiler = new MiniProfiler("", new());
using (var _ = profiler.Step("")) {
Thread.Sleep(1000);
}
profiler.Stop();
Console.WriteLine($"Profiler duration ms: {profiler.DurationMilliseconds}");Metadata
Metadata
Assignees
Labels
No labels
