예제 #1
0
        public void IncrementCounter(int increment, int currentTicks)
        {
            _transactionCounter += increment;

            // If it's less then a second then wait
            int measureInterval = currentTicks - _transactionMeter.LastMeasuredTicks;

            if (measureInterval >= 1000 && _result != null)
            {
                lock (_syncRoot)
                {
                    measureInterval = currentTicks - _transactionMeter.LastMeasuredTicks;
                    if (measureInterval >= 1000)
                    {
                        // Perform measurements
                        _transactionMeter.SetTransactionCounter(_transactionCounter);
                        _transactionCounter = 0;
                        _transactionMeter.Measure();
                        _cpuLoadMeter.Measure();
                        _memoryUsageMeter.Measure();

                        // Store measurement results
                        _result.ElapsedTime            = DateTime.Now - _result.StartTime;
                        _result.PerformanceMeasurement = _transactionMeter.Measurement;
                        _result.CpuLoadMeasurement     = _cpuLoadMeter.Measurement;
                        _result.MemoryUsageMeasurement = _memoryUsageMeter.Measurement;

                        _results.NotifyUpdated(_result);
                    }
                }
            }
        }