/// <summary>Takes current snapshot.</summary> /// <remarks>Not thread-safe. Caller should ensure that it's not called from different threads at once.</remarks> public ConsensusManagerPerformanceSnapshot TakeSnapshot() { var newSnapshot = new ConsensusManagerPerformanceSnapshot(); ConsensusManagerPerformanceSnapshot previousSnapshot = this.currentSnapshot; this.currentSnapshot = newSnapshot; return(previousSnapshot); }
public IDisposable MeasureBlockDisconnectedSignal() { var stopwatch = new StopwatchDisposable(elapsedTicks => { ConsensusManagerPerformanceSnapshot snapshot = this.currentSnapshot; Interlocked.Increment(ref snapshot.BlockDisconnectedSignal.TotalExecutionsCount); Interlocked.Add(ref snapshot.BlockDisconnectedSignal.TotalDelayTicks, elapsedTicks); }); return(stopwatch); }
public ConsensusManagerPerformanceCounter() { this.currentSnapshot = new ConsensusManagerPerformanceSnapshot(); }
public ConsensusManagerPerformanceCounter(ChainIndexer chainIndexer) { this.chainIndexer = chainIndexer; this.currentSnapshot = new ConsensusManagerPerformanceSnapshot(this.chainIndexer); }