Unverified Commit 1e5afd46 authored by 彭伟's avatar 彭伟 Committed by GitHub

Fix more than 99 times of elapsed time on Linux (#1433)

parent 69cbf695
...@@ -8,6 +8,8 @@ namespace StackExchange.Redis.Profiling ...@@ -8,6 +8,8 @@ namespace StackExchange.Redis.Profiling
{ {
internal sealed class ProfiledCommand : IProfiledCommand internal sealed class ProfiledCommand : IProfiledCommand
{ {
private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency;
#region IProfiledCommand Impl #region IProfiledCommand Impl
public EndPoint EndPoint => Server.EndPoint; public EndPoint EndPoint => Server.EndPoint;
...@@ -19,15 +21,21 @@ internal sealed class ProfiledCommand : IProfiledCommand ...@@ -19,15 +21,21 @@ internal sealed class ProfiledCommand : IProfiledCommand
public DateTime CommandCreated => MessageCreatedDateTime; public DateTime CommandCreated => MessageCreatedDateTime;
public TimeSpan CreationToEnqueued => TimeSpan.FromTicks(EnqueuedTimeStamp - MessageCreatedTimeStamp); public TimeSpan CreationToEnqueued => GetElapsedTime(EnqueuedTimeStamp - MessageCreatedTimeStamp);
public TimeSpan EnqueuedToSending => GetElapsedTime(RequestSentTimeStamp - EnqueuedTimeStamp);
public TimeSpan EnqueuedToSending => TimeSpan.FromTicks(RequestSentTimeStamp - EnqueuedTimeStamp); public TimeSpan SentToResponse => GetElapsedTime(ResponseReceivedTimeStamp - RequestSentTimeStamp);
public TimeSpan SentToResponse => TimeSpan.FromTicks(ResponseReceivedTimeStamp - RequestSentTimeStamp); public TimeSpan ResponseToCompletion => GetElapsedTime(CompletedTimeStamp - ResponseReceivedTimeStamp);
public TimeSpan ResponseToCompletion => TimeSpan.FromTicks(CompletedTimeStamp - ResponseReceivedTimeStamp); public TimeSpan ElapsedTime => GetElapsedTime(CompletedTimeStamp - MessageCreatedTimeStamp);
public TimeSpan ElapsedTime => TimeSpan.FromTicks(CompletedTimeStamp - MessageCreatedTimeStamp); [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static TimeSpan GetElapsedTime(long timestampDelta)
{
return new TimeSpan((long)(TimestampToTicks * timestampDelta));
}
public IProfiledCommand RetransmissionOf => OriginalProfiling; public IProfiledCommand RetransmissionOf => OriginalProfiling;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment