/// <summary>
 /// Gets the points per day measurement based the given frame time, work unit information, and the unit completion time.
 /// </summary>
 /// <param name="frameTime">The work unit frame time.</param>
 /// <param name="protein">The work unit information.</param>
 /// <param name="unitTime">The overall unit completion time.</param>
 /// <returns>The points per day for the work unit.</returns>
 public static double GetPPD(TimeSpan frameTime, Protein protein, TimeSpan unitTime)
 {
    return GetPPD(frameTime,
                  protein.Frames,
                  protein.Credit,
                  protein.KFactor,
                  protein.PreferredDays,
                  protein.MaximumDays,
                  unitTime);
 }
 /// <summary>
 /// Gets the points per day measurement based the given frame time, work unit information, and the unit completion time.
 /// </summary>
 /// <param name="frameTime">The work unit frame time.</param>
 /// <param name="protein">The work unit information.</param>
 /// <param name="calculateUnitTimeByFrameTime"></param>
 /// <returns>The points per day for the work unit.</returns>
 public static double GetPPD(TimeSpan frameTime, Protein protein, bool calculateUnitTimeByFrameTime)
 {
    return GetPPD(frameTime,
                  protein.Frames,
                  protein.Credit,
                  protein.KFactor,
                  protein.PreferredDays,
                  protein.MaximumDays,
                  calculateUnitTimeByFrameTime ? TimeSpan.FromSeconds(frameTime.TotalSeconds * protein.Frames) : TimeSpan.Zero);
 }
Exemple #3
0
 public void DefaultValueTest()
 {
     var protein = new Protein();
      Assert.AreEqual(0, protein.ProjectNumber);
      Assert.AreEqual("0.0.0.0", protein.ServerIP);
      Assert.AreEqual("Unknown", protein.WorkUnitName);
      Assert.AreEqual(0, protein.NumberOfAtoms);
      Assert.AreEqual(0, protein.PreferredDays);
      Assert.AreEqual(0, protein.MaximumDays);
      Assert.AreEqual(0, protein.Credit);
      Assert.AreEqual(100, protein.Frames);
      Assert.AreEqual("Unknown", protein.Core);
      Assert.AreEqual("Unassigned Description", protein.Description);
      Assert.AreEqual("Unknown", protein.Contact);
      Assert.AreEqual(0, protein.KFactor);
 }
        public void CreditUPDAndPPDTest1()
        {
            var protein = new Protein { ProjectNumber = 1, Credit = 100, KFactor = 5, PreferredDays = 3, MaximumDays = 6 };
             var utcNow = DateTime.UtcNow;
             var unitInfo = new UnitInfo { FinishedTime = utcNow, DownloadTime = utcNow.Subtract(TimeSpan.FromHours(2)), FramesObserved = 4 };
             unitInfo.SetUnitFrame(MakeUnitFrame("00:00:00", 0));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:04:00", 1));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:09:00", 2));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:15:00", 3));
             var unitInfoLogic = CreateUnitInfoLogic(protein, unitInfo);
             unitInfoLogic.UtcOffsetIsZero = false;
             unitInfoLogic.ClientTimeOffset = 0;

             Assert.AreEqual(848.528, unitInfoLogic.GetCredit(SlotStatus.RunningNoFrameTimes, PpdCalculationType.LastFrame, BonusCalculationType.DownloadTime));
             Assert.AreEqual(2.4, unitInfoLogic.GetUPD(PpdCalculationType.LastFrame));
             Assert.AreEqual(2036.4672, unitInfoLogic.GetPPD(SlotStatus.RunningNoFrameTimes, PpdCalculationType.LastFrame, BonusCalculationType.DownloadTime));
        }
 public void GetProductionValues_Test1()
 {
    var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
    var values = ProductionCalculator.GetProductionValues(TimeSpan.FromMinutes(5), protein, 
                                                          TimeSpan.FromMinutes(5 * 100).Add(TimeSpan.FromMinutes(10)),
                                                          TimeSpan.FromMinutes(5 * 100));
    Assert.AreEqual(TimeSpan.FromMinutes(5), values.TimePerFrame);
    Assert.AreEqual(700, values.BaseCredit);
    Assert.AreEqual(2016.0, values.BasePPD);
    Assert.AreEqual(TimeSpan.FromDays(3), values.PreferredTime);
    Assert.AreEqual(TimeSpan.FromDays(5), values.MaximumTime);
    Assert.AreEqual(26.4, values.KFactor);
    Assert.AreEqual(TimeSpan.FromMinutes(5 * 100).Add(TimeSpan.FromMinutes(10)), values.UnitTimeByDownloadTime);
    Assert.AreEqual(19.31, values.DownloadTimeBonusMulti, 0.01);
    Assert.AreEqual(13513.913, values.DownloadTimeBonusCredit);
    Assert.AreEqual(38920.07, values.DownloadTimeBonusPPD, 0.01);
    Assert.AreEqual(TimeSpan.FromMinutes(5 * 100), values.UnitTimeByFrameTime);
    Assert.AreEqual(19.5, values.FrameTimeBonusMulti, 0.01);
    Assert.AreEqual(13648.383, values.FrameTimeBonusCredit);
    Assert.AreEqual(39307.35, values.FrameTimeBonusPPD, 0.01);
 }
Exemple #6
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 #7
0
 public void GetMultiplierTest1()
 {
     var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
      Assert.AreEqual(19.5, protein.GetMultiplier(TimeSpan.FromMinutes(5 * 100), true), 0.01);
 }
Exemple #8
0
 public void Protein_IsValid_Test2()
 {
    var protein = new Protein();
    Assert.IsFalse(protein.IsValid());
 }
Exemple #9
0
 public void Protein_IsUnknown_Test2()
 {
    var protein = new Protein();
    Assert.IsTrue(protein.IsUnknown());
 }
Exemple #10
0
 private void DrawGraphs(int tabIndex, IList<string> lines, IEnumerable<ProteinBenchmark> benchmarks, Protein protein)
 {
    _zedGraphManager.CreateFrameTimeGraph(GetFrameTimeGraph(tabIndex), lines, benchmarks, _graphColors);
    _zedGraphManager.CreatePpdGraph(GetPpdGraph(tabIndex), lines, benchmarks, _graphColors,
       _prefs.Get<int>(Preference.DecimalPlaces), protein, _prefs.Get<BonusCalculationType>(Preference.BonusCalculation).IsEnabled());
 }
 public void GetMultiplier_Test1()
 {
    var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
    Assert.AreEqual(19.5, ProductionCalculator.GetMultiplier(protein, TimeSpan.FromMinutes(5 * 100)), 0.01);
 }
 public void GetCredit_Test2()
 {
    var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
    Assert.AreEqual(13648.383, ProductionCalculator.GetCredit(protein, TimeSpan.FromMinutes(5 * 100)));
 }
 public void GetCredit_Test1()
 {
    var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
    Assert.AreEqual(700, ProductionCalculator.GetCredit(protein, TimeSpan.Zero));
 }
 public void GetUPD_Test1()
 {
    var protein = new Protein { Credit = 500 };
    Assert.AreEqual(2.88, ProductionCalculator.GetUPD(TimeSpan.FromMinutes(5), protein.Frames));
 }
 public void GetPPD_Test3()
 {
    var protein = new Protein();
    Assert.AreEqual(0.0, ProductionCalculator.GetPPD(TimeSpan.Zero, protein));
 }
Exemple #16
0
 private UnitInfoLogic CreateUnitInfoLogic(Protein protein, UnitInfo unitInfo)
 {
     return new UnitInfoLogic(_benchmarkCollection)
         {
            CurrentProtein = protein,
            UnitInfoData = unitInfo
         };
 }
Exemple #17
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();
             }
        }
        private static IProteinDictionary CreateProteinDictionary()
        {
            var proteins = new ProteinDictionary();

             var protein = new Protein();
             protein.ProjectNumber = 6600;
             protein.WorkUnitName = "WorkUnitName";
             protein.Core = "GROGPU2";
             protein.Credit = 450;
             protein.KFactor = 0;
             protein.Frames = 100;
             protein.NumberOfAtoms = 5000;
             protein.PreferredDays = 2;
             protein.MaximumDays = 3;
             proteins.Add(protein.ProjectNumber, protein);

             protein = new Protein();
             protein.ProjectNumber = 5797;
             protein.WorkUnitName = "WorkUnitName2";
             protein.Core = "GROGPU2";
             protein.Credit = 675;
             protein.KFactor = 2.3;
             protein.Frames = 100;
             protein.NumberOfAtoms = 7000;
             protein.PreferredDays = 2;
             protein.MaximumDays = 3;
             proteins.Add(protein.ProjectNumber, protein);

             protein = new Protein();
             protein.ProjectNumber = 8011;
             protein.WorkUnitName = "WorkUnitName3";
             protein.Core = "GRO-A4";
             protein.Credit = 106.6;
             protein.KFactor = 0.75;
             protein.Frames = 100;
             protein.NumberOfAtoms = 9000;
             protein.PreferredDays = 2.13;
             protein.MaximumDays = 4.62;
             proteins.Add(protein.ProjectNumber, protein);

             protein = new Protein();
             protein.ProjectNumber = 6903;
             protein.WorkUnitName = "WorkUnitName4";
             protein.Core = "GRO-A5";
             protein.Credit = 22706;
             protein.KFactor = 38.05;
             protein.Frames = 100;
             protein.NumberOfAtoms = 11000;
             protein.PreferredDays = 5;
             protein.MaximumDays = 12;
             proteins.Add(protein.ProjectNumber, protein);

             return proteins;
        }
Exemple #19
0
 public void Protein_IsUnknown_Test1()
 {
    var protein = new Protein { ProjectNumber = 1 };
    Assert.IsFalse(protein.IsUnknown());
 }
        private void InsertTestInternal(UnitInfo unitInfo, Protein protein, Action<IList<HistoryEntry>> verifyAction)
        {
            _database.DatabaseFilePath = TestScratchFile;

             var unitInfoLogic = new UnitInfoLogic(MockRepository.GenerateStub<IProteinBenchmarkCollection>());
             unitInfoLogic.CurrentProtein = protein;
             unitInfoLogic.UnitInfoData = unitInfo;

             _database.Insert(unitInfoLogic);

             var rows = _database.Fetch(new QueryParameters());
             verifyAction(rows);

             // test code to ensure this unit is NOT written again
             _database.Insert(unitInfoLogic);
             // verify
             rows = _database.Fetch(new QueryParameters());
             Assert.AreEqual(1, rows.Count);
        }
Exemple #21
0
 public void Protein_IsValid_Test1()
 {
    var protein = new Protein { ProjectNumber = 1, PreferredDays = 3, MaximumDays = 5, Credit = 500, Frames = 100, KFactor = 26.4 };
    Assert.IsTrue(protein.IsValid());
 }
 /// <summary>
 /// Gets the credit measurement based the given work unit information and the unit completion time.
 /// </summary>
 /// <param name="protein">The work unit information.</param>
 /// <param name="unitTime">The overall unit completion time.</param>
 /// <returns>The credit for the work unit.</returns>
 public static double GetCredit(Protein protein, TimeSpan unitTime)
 {
    return GetCredit(protein.Credit,
                     protein.KFactor,
                     protein.PreferredDays,
                     protein.MaximumDays,
                     unitTime);
 }
 public void IndexerTest3()
 {
    Assert.Throws<ArgumentException>(() => _dictionary[1] = new Protein());
 }
 /// <summary>
 /// Gets the production bonus multiplier.
 /// </summary>
 /// <param name="protein">The work unit information.</param>
 /// <param name="unitTime">The overall unit completion time.</param>
 /// <returns>The production bonus multiplier.</returns>
 public static double GetMultiplier(Protein protein, TimeSpan unitTime)
 {
    return GetMultiplier(protein.KFactor,
                         protein.PreferredDays,
                         protein.MaximumDays,
                         unitTime);
 }
Exemple #25
0
 public void GetCreditTest2()
 {
     var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 };
      Assert.AreEqual(13648.383, protein.GetCredit(TimeSpan.FromMinutes(5 * 100), true));
 }
 /// <summary>
 /// Gets all production measurements based the given frame time, work unit information, and the unit completion time.
 /// </summary>
 /// <param name="frameTime">The work unit frame time.</param>
 /// <param name="protein">The work unit information.</param>
 /// <param name="unitTimeByDownloadTime">The overall unit completion time based on the unit's download time.</param>
 /// <param name="unitTimeByFrameTime">The overall unit completion time based on the unit's current frame time.</param>
 /// <returns>The production measurements for the work unit.</returns> 
 public static ProductionValues GetProductionValues(TimeSpan frameTime, Protein protein, TimeSpan unitTimeByDownloadTime, TimeSpan unitTimeByFrameTime)
 {
    return GetProductionValues(frameTime,
                               protein.Frames,
                               protein.Credit,
                               protein.KFactor,
                               protein.PreferredDays,
                               protein.MaximumDays,
                               unitTimeByDownloadTime,
                               unitTimeByFrameTime);
 }
Exemple #27
0
 public void GetPPDTest1()
 {
     var protein = new Protein { Credit = 500 };
      Assert.AreEqual(1440.0, protein.GetPPD(TimeSpan.FromMinutes(5)));
 }
 /// <summary>
 /// Gets the points per day measurement based the given frame time, work unit information, and the unit completion time.
 /// </summary>
 /// <param name="frameTime">The work unit frame time.</param>
 /// <param name="protein">The work unit information.</param>
 /// <returns>The points per day for the work unit.</returns>
 public static double GetPPD(TimeSpan frameTime, Protein protein)
 {
    return GetPPD(frameTime, protein, false);
 }
Exemple #29
0
 public void GetPPDTest3()
 {
     var protein = new Protein();
      Assert.AreEqual(0.0, protein.GetPPD(TimeSpan.Zero));
 }
Exemple #30
0
        public void TimePerSectionTest4()
        {
            var protein = new Protein { ProjectNumber = 1, Credit = 100 };
             var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow, FramesObserved = 4 };
             unitInfo.SetUnitFrame(MakeUnitFrame("00:00:00", 0));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:04:00", 1));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:09:00", 2));
             unitInfo.SetUnitFrame(MakeUnitFrame("00:15:00", 3));
             unitInfo.UnitRetrievalTime = unitInfo.DownloadTime.Add(TimeSpan.FromMinutes(30));
             var unitInfoLogic = CreateUnitInfoLogic(protein, unitInfo);
             unitInfoLogic.UtcOffsetIsZero = true;
             unitInfoLogic.ClientTimeOffset = 0;

             Assert.AreEqual(600, unitInfoLogic.GetRawTime(PpdCalculationType.EffectiveRate));
             Assert.AreEqual(TimeSpan.FromSeconds(600), unitInfoLogic.GetFrameTime(PpdCalculationType.EffectiveRate));
        }