Пример #1
0
        public Bitmap Render(PerfTestSuite suite, PerfTest test)
        {
            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
            Render(bmp,suite,test);

            return bmp;
        }
Пример #2
0
        public IDictionary Render(PerfTestSuite suite)
        {
            if (suite==null)
                throw new ArgumentNullException("suite");

            Hashtable bitmaps = new Hashtable();
            foreach(PerfTest test in suite.Tests)
            {
                bitmaps.Add(test, Render(suite,test));
            }
            return bitmaps;
        }
Пример #3
0
        public void Render(Bitmap bmp, PerfTestSuite suite, PerfTest test)
        {
            if (bmp==null)
                throw new ArgumentNullException("bmp");
            if (suite==null)
                throw new ArgumentNullException("suite");
            if (!suite.Tests.Contains(test))
                throw new ArgumentException("suite does not contain test");
            if (test.Runs.Count==0)
                throw new ArgumentException("no run in benchmark");

            Hashtable resultDatas = new Hashtable();
            PerfTestRun firstRun = test.Runs[0];
            foreach(PerfResult result in firstRun.Results)
            {
                resultDatas[result.TestedType] = new double[test.Runs.Count];
            }
            foreach(PerfFailedResult failedResult in firstRun.FailedResults)
            {
                resultDatas[failedResult.TestedType] = new double[test.Runs.Count];
            }

            // setting up histograms
            int index = 0;
            foreach(PerfTestRun run in test.Runs)
            {
                AddResult(run,resultDatas, index++);
            }

            // creating lines
            PlotSurface2D plot = CreatePlot(suite,test);
            double[] xData = CreateFeatureData(test);
            this.Colors.Reset(resultDatas.Count);
            foreach(DictionaryEntry de in resultDatas)
            {
                AddLine(plot, xData, (double[])de.Value, (string)de.Key);
            }

            if (plot.YAxis1!=null)
                plot.YAxis1.Label = "Duration [log(s)]";
            if (suite.FeatureDescription!=null && plot.XAxis1!=null)
                plot.XAxis1.Label = suite.FeatureDescription;

            // plot refresh
            Graphics g = Graphics.FromImage(bmp);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.FillRectangle(new SolidBrush(Color.LightGray), new Rectangle(0,0,bmp.Width,bmp.Height));
            plot.Draw(g, new Rectangle(0,0,bmp.Width,bmp.Height));
        }
Пример #4
0
        internal PlotSurface2D CreatePlot(PerfTestSuite suite, PerfTest test)
        {
            PlotSurface2D plot = new PlotSurface2D();

            plot.Title = String.Format("{0} - {1}", suite.Name, test.Name);
            // setting up plot
            plot.LegendBorderStyle = Legend.BorderType.Shadow;
            plot.ShowLegend = true;
            plot.PlotBackColor = Color.White;
            plot.VerticalEdgeLegendPlacement = Legend.Placement.Outside;

            return plot;
        }
Пример #5
0
        public PerfTestSuite RunTests()
        {
            PerfTestSuite suite = new PerfTestSuite(this.TesterType, this.Description, this.FeatureDescription);

            foreach(MethodInfo test in this.methods)
            {
                PerfTest testResult = new PerfTest(test);
                if (testResult.IsIgnored)
                {
                    OnIgnoredTest(testResult);
                    suite.Tests.Add(testResult);
                    continue;
                }

                OnStartTest(testResult);

                for(int testIndex = 0;testIndex<this.TestCount;++testIndex)
                {
                    PerfTestRun run = new PerfTestRun(RunDescription(testIndex));

                    OnStartRun(run);

                    // for each instanced type,
                    foreach(Type t in this.testedTypes)
                    {
                        try
                        {
                            //jitting if first run of the test
                            if (testIndex==0)
                                RunTest(-1,t,test,false);

                            // calling
                            RunTest(testIndex,t,test,true);

                            // save results
                            run.Results.Add(new PerfResult(t,this.timer.Duration,this.memorizer.Usage));
                        }
                        catch(Exception ex)
                        {
                            run.FailedResults.Add(new PerfFailedResult(t,ex));
                        }
                    }
                    OnFinishRun(run);
                    testResult.Runs.Add(run);
                }
                OnFinishTest(testResult);
                suite.Tests.Add(testResult);
            }
            return suite;
        }
Пример #6
0
 public ResultsChangeEventArgs(PerfTestSuite results)
 {
     CurrentResults = results;
 }
Пример #7
0
        public PerfTestSuite RunTests()
        {
            PerfTestSuite suite = new PerfTestSuite(this.TesterType, this.Description, this.FeatureDescription);

            for (int testIndex = 0; testIndex < this.methods.Count;testIndex++)
            {
                MethodInfo test = methods[testIndex];
                PerfTest testResult = new PerfTest(test);
                //Adding from the start
                suite.Tests.Add(testResult);

                if (testResult.IsIgnored)
                {
                    OnIgnoredTest(testResult);
                    suite.Tests.Add(testResult);
                    continue;
                }

                OnStartTest(testResult);

                for (int runIndex = 0; runIndex < this.TestCount; ++runIndex)
                {

                    PerfTestRun run = new PerfTestRun(IsRunDescriptorValueOveridden ? TestStart + runIndex * TestStep : RunDescription(runIndex));

                    OnStartRun(run);

                    // for each instanced type,
                    foreach (Type t in this.testedTypes)
                    {
                        try
                        {
                            //jitting if first run of the test
                            if (runIndex == 0)
                                RunTest(-1, t, test, false);

                            // calling
                            RunTest(runIndex, t, test, true);

                            // save results
                            run.Results.Add(new PerfResult(t, this.timer.Duration, this.memorizer.Usage));
                        }
                        catch (Exception ex)
                        {
                            run.FailedResults.Add(new PerfFailedResult(t, ex));
                        }
                    }
                    OnFinishRun(run);
                    testResult.Runs.Add(run);

                    //Adding to suite
                    suite.Tests[testIndex] = testResult;
                    //Invoking Event Handler
                    OnResultsChange(this, new ResultsChangeEventArgs(suite));
                }
                OnFinishTest(testResult);

                //suite.Tests[testIndex] = testResult;

            }
            return suite;
        }