/// <summary> /// Initializes a new instance of the <see cref="T:ExitGames.Diagnostics.Counter.AverageCounter"/> class. /// </summary> /// <param name="name">The counter name.</param> public AverageCounter(string name) : base(name) { this.sharedCounter = new SharedCounter(name); this.sharedCounterBase = new SharedCounter(name); this.oldSample = this.GetNextSample(); }
/// <summary> /// Returns the average count since the last <see /// cref="M:ExitGames.Diagnostics.Counter.AverageCounter.GetNextValue"/> call. /// </summary> /// <returns>The new average value. </returns> /// <remarks>This method is NOT thread safe. </remarks> public override float GetNextValue() { RawCounterSample sample = this.oldSample; RawCounterSample nextSample = this.GetNextSample(); this.oldSample = nextSample; long num = nextSample.BaseValue - sample.BaseValue; long num2 = nextSample.Value - sample.Value; if (num == 0L) { return(0f); } return((float)num2 / (float)num); }