public void Should_measure_time_correctly() { var watch = LeanStopwatch.StartNew(); Thread.Sleep(TimeSpan.FromSeconds(1)); var watchElapsed = watch.ElapsedTimeSpan; watchElapsed .Should() .BeGreaterThan(TimeSpan.FromSeconds(0.97)) .And .BeLessThan(TimeSpan.FromSeconds(1.03)); }
/// <summary> /// Sends gauge metric into a <see cref="IStatsdClient"/> /// </summary> /// <param name="self">An instance of the <see cref="IStatsdClient"/></param> /// <param name="name">Name of a metric</param> /// <param name="stopwatch">An instance of <see cref="LeanStopwatch"/> which will be used to determine time interval</param> public static IStatsdClient LogTiming(this IStatsdClient self, string name, LeanStopwatch stopwatch) { self.LogTiming(stopwatch.Elapsed(name)); return(self); }