/// <summary> /// Copy this histogram into the target histogram, overwriting it's contents. /// </summary> /// <param name="source">The source histogram</param> /// <param name="targetHistogram">the histogram to copy into</param> public static void CopyInto(this HistogramBase source, HistogramBase targetHistogram) { targetHistogram.Reset(); targetHistogram.Add(source); targetHistogram.StartTimeStamp = source.StartTimeStamp; targetHistogram.EndTimeStamp = source.EndTimeStamp; }
/// <summary> /// Copy this histogram, corrected for coordinated omission, into the target histogram, overwriting it's contents. /// </summary> /// <param name="targetHistogram">the histogram to copy into</param> /// <param name="expectedIntervalBetweenValueSamples">If <paramref name="expectedIntervalBetweenValueSamples"/> is larger than 0, add auto-generated value records as appropriate if value is larger than <paramref name="expectedIntervalBetweenValueSamples"/></param> /// <remarks> /// See <see cref="CopyCorrectedForCoordinatedOmission"/> for more detailed explanation about how correction is applied /// </remarks> public void CopyIntoCorrectedForCoordinatedOmission(HistogramBase targetHistogram, long expectedIntervalBetweenValueSamples) { targetHistogram.Reset(); targetHistogram.AddWhileCorrectingForCoordinatedOmission(this, expectedIntervalBetweenValueSamples); targetHistogram.StartTimeStamp = StartTimeStamp; targetHistogram.EndTimeStamp = EndTimeStamp; }
private void PerformIntervalSample() { try { _recordingPhaser.ReaderLock(); // Make sure we have an inactive version to flip in: if (_inactiveHistogram == null) { _inactiveHistogram = _histogramFactory(_instanceId, _activeHistogram.LowestTrackableValue, _activeHistogram.HighestTrackableValue, _activeHistogram.NumberOfSignificantValueDigits); } _inactiveHistogram.Reset(); // 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 = DateTime.Now.MillisecondsSinceUnixEpoch(); _activeHistogram.StartTimeStamp = now; _inactiveHistogram.EndTimeStamp = 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(TimeSpan.FromMilliseconds(0.5)); } finally { _recordingPhaser.ReaderUnlock(); } }