Commit cf238f30 authored by Nick Craver's avatar Nick Craver

Revert "Accurate timespan if the stopwatch is high resolution (#1230)"

This reverts commit a683d9c8.
parent 5914a91f
......@@ -19,15 +19,15 @@ internal sealed class ProfiledCommand : IProfiledCommand
public DateTime CommandCreated => MessageCreatedDateTime;
public TimeSpan CreationToEnqueued => TimeSpanHelper.FromStopwatchTicks(EnqueuedTimeStamp - MessageCreatedTimeStamp);
public TimeSpan CreationToEnqueued => TimeSpan.FromTicks(EnqueuedTimeStamp - MessageCreatedTimeStamp);
public TimeSpan EnqueuedToSending => TimeSpanHelper.FromStopwatchTicks(RequestSentTimeStamp - EnqueuedTimeStamp);
public TimeSpan EnqueuedToSending => TimeSpan.FromTicks(RequestSentTimeStamp - EnqueuedTimeStamp);
public TimeSpan SentToResponse => TimeSpanHelper.FromStopwatchTicks(ResponseReceivedTimeStamp - RequestSentTimeStamp);
public TimeSpan SentToResponse => TimeSpan.FromTicks(ResponseReceivedTimeStamp - RequestSentTimeStamp);
public TimeSpan ResponseToCompletion => TimeSpanHelper.FromStopwatchTicks(CompletedTimeStamp - ResponseReceivedTimeStamp);
public TimeSpan ResponseToCompletion => TimeSpan.FromTicks(CompletedTimeStamp - ResponseReceivedTimeStamp);
public TimeSpan ElapsedTime => TimeSpanHelper.FromStopwatchTicks(CompletedTimeStamp - MessageCreatedTimeStamp);
public TimeSpan ElapsedTime => TimeSpan.FromTicks(CompletedTimeStamp - MessageCreatedTimeStamp);
public IProfiledCommand RetransmissionOf => OriginalProfiling;
......
using System;
using System.Diagnostics;
namespace StackExchange.Redis.Profiling
{
/// <summary>
/// A helper class for dealing with Low/High Resolution Stopwatches and their ticks
/// </summary>
internal static class TimeSpanHelper
{
/// <summary>
/// Used to construct a timespan from ticks obtained using Stopwatch.GetTimestamp()
/// </summary>
/// <param name="ticks"></param>
/// <returns>A TimeSpan constructed from the ticks</returns>
internal static TimeSpan FromStopwatchTicks(long ticks)
{
return Stopwatch.IsHighResolution ? TimeSpan.FromMilliseconds(ticks / ((double) Stopwatch.Frequency / 1000)) : TimeSpan.FromTicks(ticks);
}
}
}
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