コード例 #1
0
        public void TestPerformanceCounterValuesAreCorrectlyRetrievedUsingRawCounterGauge()
        {
            RawCounterGauge gauge = new RawCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", "privateBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests());
            double          value = gauge.GetValueAndReset();

            Assert.IsTrue(value > 0);
        }
コード例 #2
0
        public void RateCounterGaugeGetValueAndResetGetsTheValueFromJson()
        {
            RawCounterGauge readIoBytes  = new RawCounterGauge("READ IO BYTES", "readIoBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests());
            RawCounterGauge writeIoBytes = new RawCounterGauge("WRITE IO BYTES", "writeIoBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests());
            RawCounterGauge otherIoBytes = new RawCounterGauge("OTHER IO BYTES", "otherIoBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests());

            RatioCounterGauge readIoBytesRate = new RatioCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", readIoBytes, writeIoBytes);

            double value1 = readIoBytesRate.Collect();

            Assert.IsTrue(value1 != 0);

            SumUpCountersGauge writeAndOtherBytes   = new SumUpCountersGauge("Sum Up Bytes", writeIoBytes, otherIoBytes);
            RatioCounterGauge  totalReadIoBytesRate = new RatioCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", readIoBytes, writeAndOtherBytes);
            double             value2 = totalReadIoBytesRate.Collect();

            Assert.IsTrue(value2 != 0);
            Assert.IsTrue(value1 >= value2);

            RatioCounterGauge totalReadIoBytesPercentage = new RatioCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", readIoBytes, writeAndOtherBytes, 100);
            double            percentage = totalReadIoBytesPercentage.Collect();

            Assert.IsTrue(percentage != 0);
            Assert.IsTrue(Math.Abs((value2 * 100) - percentage) < 1);
        }
        public void RateCounterGaugeGetValueAndResetGetsTheValueFromJson()
        {
            SumUpCountersGauge twoTimesPrivateBytes = new SumUpCountersGauge(
                "twoTimesPrivateBytes",
                new RawCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes * 2", "privateBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests()),
                new RawCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", "privateBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests()));

            RawCounterGauge privateBytes = new RawCounterGauge(@"\Process(??APP_WIN32_PROC??)\Private Bytes", "privateBytes", AzureWebApEnvironmentVariables.App, new CacheHelperTests());

            double expectedValue = privateBytes.Collect();
            double actualValue   = twoTimesPrivateBytes.Collect();

            // twoTimesPrivateBytes is -greater than (privateBytes * 1.85) but lower than (privateBytes * 2.15).
            Assert.IsTrue((expectedValue * 1.85) < actualValue && (expectedValue * 2.15) > actualValue);
        }