Пример #1
0
        private void PerformIntervalSample()
        {
            inactiveHistogram.reset();
            try
            {
                recordingPhaser.ReaderLock();

                // Swap active and inactive histograms:
                var tempHistogram = inactiveHistogram;
                inactiveHistogram = activeHistogram;
                activeHistogram   = tempHistogram;

                // Mark end time of previous interval and start time of new one:
                var now = CurentTimeInMilis();
                activeHistogram.setStartTimeStamp(now);
                inactiveHistogram.setEndTimeStamp(now);

                // Make sure we are not in the middle of recording a value on the previously active histogram:

                // Flip phase to make sure no recordings that were in flight pre-flip are still active:
                recordingPhaser.FlipPhase(500000L /* yield in 0.5 msec units if needed */);
            }
            finally
            {
                recordingPhaser.ReaderUnlock();
            }
        }
Пример #2
0
 /// <summary>
 ///     Construct an auto-resizing Recorder with a lowest discernible value of
 ///     1 and an auto-adjusting highestTrackableValue. Can auto-resize up to track values up to (long.MaxValue / 2).
 /// </summary>
 /// <param name="numberOfSignificantValueDigits">
 ///     Specifies the precision to use. This is the number of significant decimal
 ///     digits to which the histogram will maintain value resolution and separation. Must be a non-negative integer between
 ///     0 and 5.
 /// </param>
 public Recorder(int numberOfSignificantValueDigits)
 {
     activeHistogram   = new InternalConcurrentHistogram(instanceId, numberOfSignificantValueDigits);
     inactiveHistogram = new InternalConcurrentHistogram(instanceId, numberOfSignificantValueDigits);
     activeHistogram.setStartTimeStamp(CurentTimeInMilis());
 }