Beispiel #1
0
        private static void SetupDummyCounters()
        {
            useDummyCounters = true;

            ConnectedClients           = new DummyCounter(connectedClients);
            FlushEventRoundTripTime    = new DummyCounter(flusheventRoundtripTime);
            FlushEventsReceived        = new DummyCounter(flusheventsReceivedSec);
            FlushOperationsSent        = new DummyCounter("Flush Operations Sent / sec");
            ReceivedOperationResponse  = new DummyCounter(receivedOperationResponsesSec);
            ReliableEventsReceived     = new DummyCounter(reliableEventsReceivedSec);
            ReliableEventRoundTripTime = new DummyCounter(reliableEventRoundtripTime);
            ReliableOperationsSent     = new DummyCounter(reliableOperationsSentSec);
            RoundTripTime                = new DummyCounter(roundtripTime);
            RoundTripTimeVariance        = new DummyCounter(roundtripTimeVariance);
            UnreliableEventRoundTripTime = new DummyCounter(unreliableEventRoundtripTime);
            UnreliableEventsReceived     = new DummyCounter(unreliableEventsReceivedSec);
            UnreliableOperationsSent     = new DummyCounter(unreliableOperationsSentSec);

            // Base counters:
            FlusheventRoundtripTimeBase    = new DummyCounter(flushEventRoundtripTimeBase);
            ReliableEventRoundtripTimeBase = new DummyCounter(reliableEventRoundtripTimeBase);
            RoundtripTimeBase                = new DummyCounter(roundtripTimeBase);
            RoundtripTimeVarianceBase        = new DummyCounter(roundtripTimeVarianceBase);
            UnreliableEventRoundtripTimeBase = new DummyCounter(unreliableEventRoundtripTimeBase);
        }
Beispiel #2
0
        /// <summary>
        /// Tries to create a <see cref="T:ExitGames.Diagnostics.Counter.ICounter"/> wrapper for an <see cref="T:System.Diagnostics.PerformanceCounter"/>.
        /// </summary>
        /// <param name="name">The counter name.</param>
        /// <param name="performanceCounterCategory">The name of the performance counter category (performance object) with which this performance counter is associated.</param>
        /// <param name="performanceCounterName">The name of the performance counter.</param>
        /// <param name="performanceCounterInstance">The name of the performance counter category instance, or an empty string (""), if the category contains a single instance.</param>
        /// <returns>If the performance counter creation succeds an instance of <see
        /// cref="T:ExitGames.Diagnostics.Counter.WindowsPerformanceCounter"/>
        /// is returned, otherwise an instance of <see
        /// cref="T:ExitGames.Diagnostics.Counter.DummyCounter"/> is returned.</returns>
        public static ICounter TryCreateWindowsCounter(string name, string performanceCounterCategory, string performanceCounterName, string performanceCounterInstance)
        {
            ICounter counter2;

            try
            {
                if (!PerformanceCounterCategory.Exists(performanceCounterCategory))
                {
                    if (log.IsWarnEnabled)
                    {
                        LogPerformanceCounterError(performanceCounterCategory, performanceCounterName, performanceCounterInstance, "Performance counter category does not exists.");
                    }
                    return(new DummyCounter(name));
                }
                PerformanceCounter counter = new PerformanceCounter(performanceCounterCategory, performanceCounterName, performanceCounterInstance, true);
                counter2 = new WindowsPerformanceCounter(counter);
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (Exception exception)
            {
                if (log.IsWarnEnabled)
                {
                    LogPerformanceCounterError(performanceCounterCategory, performanceCounterName, performanceCounterInstance, exception.Message);
                }
                counter2 = new DummyCounter(name);
            }
            return(counter2);
        }
 static BenchmarkScope()
 {
     _dummy_counter = new DummyCounter();
 }