Exemple #1
0
 public void GetPPDTest3()
 {
     var protein = new Protein();
      Assert.AreEqual(0.0, protein.GetPPD(TimeSpan.Zero));
 }
Exemple #2
0
 public void GetPPDTest1()
 {
     var protein = new Protein { Credit = 500 };
      Assert.AreEqual(1440.0, protein.GetPPD(TimeSpan.FromMinutes(5)));
 }
Exemple #3
0
 public void GetPPDTest2()
 {
     var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
      Assert.AreEqual(39307.35, protein.GetPPD(TimeSpan.FromMinutes(5), true), 0.01);
 }
Exemple #4
0
        public void CreatePpdGraph(ZedGraphControl zg, IList<string> projectInfo, 
            IEnumerable<ProteinBenchmark> benchmarks,
            IList<Color> graphColors, int decimalPlaces,
            Protein protein, bool calculateBonus)
        {
            Debug.Assert(zg != null);

             try
             {
            // get a reference to the GraphPane
            GraphPane myPane = zg.GraphPane;

            // Clear the bars
            myPane.CurveList.Clear();
            // Clear the bar labels
            myPane.GraphObjList.Clear();
            // Clear the XAxis Project Information
            myPane.XAxis.Title.Text = String.Empty;

            // If no Project Information, get out
            if (projectInfo.Count == 0)
            {
               return;
            }

            // Scale YAxis In Thousands?
            bool inThousands = false;

            // Create the bars for each benchmark
            int i = 0;
            foreach (ProteinBenchmark benchmark in benchmarks)
            {
               double minimumFrameTimePPD = 0;
               double averageFrameTimePPD = 0;
               if (protein != null)
               {
                  minimumFrameTimePPD = protein.GetPPD(benchmark.MinimumFrameTime, calculateBonus);
                  averageFrameTimePPD = protein.GetPPD(benchmark.AverageFrameTime, calculateBonus);
               }

               if (minimumFrameTimePPD >= 1000 || averageFrameTimePPD >= 1000)
               {
                  inThousands = true;
               }

               var yPoints = new double[2];
               yPoints[0] = Math.Round(minimumFrameTimePPD, decimalPlaces);
               yPoints[1] = Math.Round(averageFrameTimePPD, decimalPlaces);

               CreateBar(i, myPane, benchmark.OwningSlotName, yPoints, graphColors);
               i++;
            }

            // Create the bar labels
            BarItem.CreateBarLabels(myPane, true, String.Empty, zg.Font.Name, zg.Font.Size, Color.Black, true, false, false);

            // Set the Titles
            myPane.Title.Text = "HFM.NET - Client Benchmarks";
            var sb = new StringBuilder();
            for (i = 0; i < projectInfo.Count - 2; i++)
            {
               sb.Append(projectInfo[i]);
               sb.Append(" / ");
            }
            sb.Append(projectInfo[i]);
            myPane.XAxis.Title.Text = sb.ToString();
            myPane.YAxis.Title.Text = "PPD";

            // Draw the X tics between the labels instead of at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;
            // Set the XAxis labels
            var labels = new[] { "Min. Frame Time", "Avg. Frame Time" };
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Don't show YAxis.Scale as 10^3
            myPane.YAxis.Scale.MagAuto = false;
            // Set the YAxis Steps
            if (inThousands)
            {
               myPane.YAxis.Scale.MajorStep = 1000;
               myPane.YAxis.Scale.MinorStep = 500;
            }
            else
            {
               myPane.YAxis.Scale.MajorStep = 100;
               myPane.YAxis.Scale.MinorStep = 10;
            }

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));
             }
             finally
             {
            // Tell ZedGraph to refigure the
            // axes since the data have changed
            zg.AxisChange();
            // Refresh the control
            zg.Refresh();
             }
        }