/// <summary> /// Increments the counter. /// </summary> public virtual void Increment() { _value.Increment(); _iterations.Increment(); if (_directWrite && (_iterations.Get() % _resolution) == 0) { Write(); } }
/// <summary> /// Write the measurement data to the log system. /// </summary> public virtual void Write() { var value = _counter.Get(); var meanRate = new Rate { Value = value, TimeUnit = Abbreviate(_rateUnit), MeterType = _measuring }; if (Count != 0) { var elapsed = (DateTime.Now.Ticks - _startTime) * 100; // 1 DateTime Tick == 100ns meanRate.Value = (Count / (double)elapsed) * _rateUnit.ToNanos(1); } var oneMinuteRate = new Rate { Value = _m1Rate.Rate(_rateUnit), TimeUnit = Abbreviate(_rateUnit), MeterType = _measuring }; var fiveMinuteRate = new Rate { Value = _m5Rate.Rate(_rateUnit), TimeUnit = Abbreviate(_rateUnit), MeterType = _measuring }; var fifteenMinuteRate = new Rate { Value = _m15Rate.Rate(_rateUnit), TimeUnit = Abbreviate(_rateUnit), MeterType = _measuring }; _logger.Write(_level, _template, _name, value, meanRate, oneMinuteRate, fiveMinuteRate, fifteenMinuteRate); }
/// <summary> /// Write the measurement data to the log system. /// </summary> public virtual void Write() { var value = _value.Get(); _logger.Write(_level, _template, _name, value, _counts); }