コード例 #1
0
        /// <summary>
        /// Asserts the performance counters recorded.
        /// </summary>
        /// <param name="reporterType">Type of the reporter.</param>
        /// <param name="checkExecutionTime">if set to <c>true</c> [check execution time].</param>
        /// <param name="expectedCount">The expected count.</param>
        /// <remarks></remarks>
        private static void AssertPerformanceCountersRecorded(PerformanceCounterReporterType reporterType,
                                                              bool checkExecutionTime, int expectedCount)
        {
            PerformanceCounterReporter counterRecorder = PerformanceCounterReporterFactory.CreateReporter(reporterType);

            Assert.AreEqual(expectedCount, counterRecorder.OperationCountValue);

            Assert.IsTrue(counterRecorder.OperationCountValue > 0);
            float executionTime = counterRecorder.ExecutionTimeValue;

            Console.WriteLine(@"The execution time was reported as " + executionTime);

            // The CheckFeatureState method smokes the millisecond barrier at these cache sizes,
            // therefore this check is disabled for that method.
            if (checkExecutionTime)
            {
                Assert.IsTrue(executionTime > 0);
            }
        }
コード例 #2
0
        public void PerformanceCounterReporterFactoryCreatesInstances()
        {
            try
            {
                PerformanceCounterRegistrar.EnsureExist();

                PerformanceCounterReporter reporter =
                    PerformanceCounterReporterFactory.CreateReporter(PerformanceCounterReporterType.CreateFeature);
                Assert.IsNotNull(reporter);

                reporter =
                    PerformanceCounterReporterFactory.CreateReporter(PerformanceCounterReporterType.CheckFeatureState);
                Assert.IsNotNull(reporter);

                reporter =
                    PerformanceCounterReporterFactory.CreateReporter(PerformanceCounterReporterType.UpdateFeatureState);
                Assert.IsNotNull(reporter);
            }
            finally
            {
                PerformanceCounterRegistrar.Remove();
            }
        }