Пример #1
0
 internal virtual void LoadFullRange(IRecorder source)
 {
     for (long i = 0L; i < DefaultHighestTrackableValue; i += 100L)
     {
         source.RecordValue(i);
     }
     source.RecordValue(DefaultHighestTrackableValue);
 }
Пример #2
0
 protected override void LoadFullRange(IRecorder source)
 {
     for (long i = 0L; i < DefaultHighestTrackableValue; i += 1000L)
     {
         source.RecordValue(i);
     }
     source.RecordValue(DefaultHighestTrackableValue);
 }
 protected virtual void LoadFullRange(IRecorder source)
 {
     for (long i = 0L; i < DefaultHighestTrackableValue; i += 100L)
     {
         source.RecordValue(i);
     }
     source.RecordValue(DefaultHighestTrackableValue);
 }
Пример #4
0
 private static void LoadHistogram(IRecorder histogram)
 {
     for (int i = 0; i < 10000; i += 1000)
     {
         histogram.RecordValue(i);
     }
 }
Пример #5
0
 private static void Load(IRecorder source)
 {
     for (long i = 0L; i < 10000L; i++)
     {
         source.RecordValue(1000L * i);
     }
 }
 private static void Load(IRecorder source)
 {
     for (long i = 0L; i < 10000L; i++)
     {
         source.RecordValue(1000L * i);
     }
 }
 private static void LoadHistogram(IRecorder histogram)
 {
     for (int i = 0; i < 10000; i += 1000)
     {
         histogram.RecordValue(i);
     }
 }
Пример #8
0
        /// <summary>
        /// Executes the action and records the time to complete the action.
        /// The time is recorded in system clock ticks.
        /// This time may vary between frameworks and platforms, but is equivalent to <c>(1/Stopwatch.Frequency)</c> seconds.
        /// Note this is a convenience method and can carry a cost.
        /// If the <paramref name="action"/> delegate is not cached, then it may incur an allocation cost for each invocation of <see cref="Record"/>
        /// </summary>
        /// <param name="recorder">The <see cref="IRecorder"/> instance to record the latency in.</param>
        /// <param name="action">The functionality to execute and measure</param>
        /// <remarks>
        /// <para>
        /// The units returned from <code>Stopwatch.GetTimestamp()</code> are used as the unit of
        /// recording here as they are the smallest unit that .NET can measure and require no
        /// conversion at time of recording.
        /// Instead conversion (scaling) can be done at time of output to microseconds, milliseconds,
        /// seconds or other appropriate unit.
        /// These units are sometimes referred to as ticks, but should not not to be confused with
        /// ticks used in <seealso cref="DateTime"/> or <seealso cref="TimeSpan"/>.
        /// </para>
        /// <para>
        /// If you are able to cache the <paramref name="action"/> delegate, then doing so is encouraged.
        /// <example>
        /// Here are two examples.
        /// The first does not cache the delegate
        ///
        /// <code>
        /// for (long i = 0; i &lt; loopCount; i++)
        /// {
        ///   histogram.Record(IncrementNumber);
        /// }
        /// </code>
        /// This second example does cache the delegate
        /// <code>
        /// Action incrementNumber = IncrementNumber;
        /// for (long i = 0; i &lt; loopCount; i++)
        /// {
        ///   histogram.Record(incrementNumber);
        /// }
        /// </code>
        /// In the second example, we will not be making allocations each time i.e. an allocation of an <seealso cref="Action"/> from <code>IncrementNumber</code>.
        /// This will reduce memory pressure and therefore garbage collection penalties.
        /// For performance sensitive applications, this method may not be suitable.
        /// As always, you are encouraged to test and measure the impact for your scenario.
        /// </example>
        /// </para>
        /// </remarks>
        public static void Record(this IRecorder recorder, Action action)
        {
            var start = Stopwatch.GetTimestamp();

            action();
            var elapsed = Stopwatch.GetTimestamp() - start;

            recorder.RecordValue(elapsed);
        }
Пример #9
0
            public void Dispose()
            {
                var elapsed = Stopwatch.GetTimestamp() - _start;

                _recorder.RecordValue(elapsed);
            }