Пример #1
0
        /// <summary>
        /// return true if regression found
        /// These tests will be affected by other tests running in the same instance of testhost because they share the same memory
        /// </summary>
        private async Task <bool> DoStressSimulation(int nIter, int nArraySize, float RatioThresholdSensitivity, Action action = null)
        {
            var lstPCs = PerfCounterData.GetPerfCountersToUse(Process.GetCurrentProcess(), IsForStress: true);

            foreach (var ctr in lstPCs)
            {
                ctr.IsEnabledForMeasurement = true;
            }
            List <LeakAnalysisResult> lstRegResults;

            using (var measurementHolder = new MeasurementHolder(
                       new TestContextWrapper(TestContext),
                       new StressUtilOptions()
            {
                NumIterations = -1, Sensitivity = RatioThresholdSensitivity, logger = this, lstPerfCountersToUse = lstPCs
            },
                       SampleType.SampleTypeIteration))
            {
                var lstBigStuff = new List <byte[]>();
                LogMessage($"nIter={nIter:n0} ArraySize= {nArraySize:n0}");
                for (int i = 0; i < nIter; i++)
                {
                    if (action != null)
                    {
                        action();
                    }
                    else
                    {
                        lstBigStuff.Add(new byte[nArraySize]);
                    }
                    //                lstBigStuff.Add(new int[10000000]);
                    var res = await measurementHolder.TakeMeasurementAsync($"iter {i}/{nIter}", DoForceGC : true);

                    LogMessage(res);
                }
                var filename = measurementHolder.DumpOutMeasurementsToTxtFile();
                LogMessage($"Results file name = {filename}");
                lstRegResults = (await measurementHolder.CalculateLeaksAsync(showGraph: false, GraphsAsFilePrefix: "Graph")).Where(r => r.IsLeak).ToList();
            }
            return(lstRegResults.Count > 0);
        }
Пример #2
0
        public async Task TestMeasureRegressionVerifyGraph()
        {
            await Task.Yield();

            var resultsFolder = string.Empty;

            using (var measurementHolder = new MeasurementHolder(
                       new TestContextWrapper(TestContext),
                       new StressUtilOptions()
            {
                NumIterations = -1, logger = this, lstPerfCountersToUse = PerfCounterData.GetPerfCountersToUse(Process.GetCurrentProcess(), IsForStress: true).Where(p => p.perfCounterType == PerfCounterType.KernelHandleCount).ToList()
            },
                       SampleType.SampleTypeIteration))
            {
                resultsFolder = measurementHolder.ResultsFolder;
                for (int iter = 0; iter < 10; iter++)
                {
                    foreach (var ctr in measurementHolder.LstPerfCounterData)
                    {
                        var val = 10000 + (uint)iter;
                        if (iter == 5 && ctr.perfCounterType == PerfCounterType.KernelHandleCount)
                        {
                            val += 1;
                        }
                        measurementHolder.measurements[ctr.perfCounterType].Add(val);
                    }
                }
                var res = await measurementHolder.CalculateLeaksAsync(showGraph : true, GraphsAsFilePrefix : "Graph");
            }
            var strHtml  = @"
<a href=""file:\\C:\Users\calvinh\Source\repos\PerfGraphVSIX\TestResults\Deploy_calvinh 2019-11-19 11_00_13/Out/TestMeasureRegressionVerifyGraph/Graph Handle Count.png"">gr </a>
            ";
            var fileHtml = Path.Combine(resultsFolder, "IndexTest1.html");

            File.WriteAllText(fileHtml, strHtml);
            TestContext.AddResultFile(fileHtml);
            Assert.Fail("failing test so results aren't deleted");
        }
Пример #3
0
        public async Task TestOutliers()
        {
            if (StressUtilOptions.IsRunningOnBuildMachine())
            {
                return;
            }
            await Task.Yield();

            // data from https://dev.azure.com/devdiv/DevDiv/_releaseProgress?_a=release-environment-extension&releaseId=548609&environmentId=2872682&extensionId=ms.vss-test-web.test-result-in-release-environment-editor-tab&runId=10533790&resultId=100000&paneView=attachments
            var testData = new uint[]
            {
                1867008,
                2713172,
                2701928,
                2701928,
                2701800,
                2701800,
                2701700,
                2701700,
                2711368,
                2711368,
                2713228,
                2713228,
                2714876,
                2714876,
                2716588,
                2716588,
                2716588,
                2732980,
                2732980,
                2734848,
                2734848,
                2736536,
                2736536,
                2738052,
                2738052,
                2739908,
                2739908,
                2741400,
                2741400,
                2742916,
                2742916,
                2744548,
                2744548,
                2744548,
                2747340,
                2747340,
                2764696,
                2764696,
                2766384,
                2766384,
                2767888,
                2767888,
                2769756,
                2769756,
                2771260,
                2771260,
                2772764,
                2772764,
                2774268,
                2774268,
                2774268,
                2776140,
                2776140,
                2777468,
                2777468,
                2779168,
                2779168,
                2779836,
                2779836,
                2797744,
                2797744,
                2799236,
                2799236,
                2800996,
                2800996,
                2803548,
                2803548,
                2899440,
                2904492,
                2904492,
                2904492,
            };

            var resultsFolder = string.Empty;

            using (var measurementHolder = new MeasurementHolder(
                       new TestContextWrapper(TestContext),
                       new StressUtilOptions()
            {
                NumIterations = -1,
                logger = this,
                pctOutliersToIgnore = 5,
                lstPerfCountersToUse = PerfCounterData.GetPerfCountersToUse(Process.GetCurrentProcess(),
                                                                            IsForStress: true).Where(p => p.perfCounterType == PerfCounterType.GCBytesInAllHeaps).ToList()
            },
                       SampleType.SampleTypeIteration))
            {
                resultsFolder = measurementHolder.ResultsFolder;
                for (int iter = 0; iter < testData.Length; iter++)
                {
                    foreach (var ctr in measurementHolder.LstPerfCounterData)
                    {
                        measurementHolder.measurements[ctr.perfCounterType].Add(testData[iter]);
                    }
                }
                var leakAnalysisResults = await measurementHolder.CalculateLeaksAsync(showGraph : false, GraphsAsFilePrefix : "Graph");

                LogMessage($"Yint = {leakAnalysisResults[0].yintercept:n0}");
                foreach (var res in leakAnalysisResults[0].lstData)
                {
                    LogMessage($"{res} dist = {res.distance} {res}");
                }
                Assert.IsTrue(leakAnalysisResults[0].lstData[0].IsOutlier);
                Assert.IsTrue(leakAnalysisResults[0].lstData[1].IsOutlier);
                Assert.IsTrue(!leakAnalysisResults[0].lstData[2].IsOutlier);
                Assert.IsTrue(leakAnalysisResults[0].lstData[68].IsOutlier);
            }
        }