private double GetPPD(TimeSpan frameTime, TimeSpan eftByDownloadTime, TimeSpan eftByFrameTime, SlotStatus status, BonusCalculationType calculateBonus) { if (CurrentProtein.IsUnknown) { return(0); } // Issue 125 if (calculateBonus.Equals(BonusCalculationType.DownloadTime)) { // Issue 183 if (status.Equals(SlotStatus.RunningAsync) || status.Equals(SlotStatus.RunningNoFrameTimes)) { return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByFrameTime)); } return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByDownloadTime)); } if (calculateBonus.Equals(BonusCalculationType.FrameTime)) { return(ProductionCalculator.GetPPD(frameTime, CurrentProtein, eftByFrameTime)); } return(ProductionCalculator.GetPPD(frameTime, CurrentProtein)); }
private void PopulateBenchmarkInformation(Protein protein, ProteinBenchmark benchmark, UnitInfoModel unitInfoModel, SlotStatus status, string ppdFormatString, ICollection <string> lines) { if (protein == null) { return; } var calculateBonus = _prefs.Get <BonusCalculationType>(Preference.BonusCalculation); lines.Add(String.Empty); lines.Add(String.Format(" Name: {0}", benchmark.OwningSlotName)); lines.Add(String.Format(" Path: {0}", benchmark.OwningClientPath)); lines.Add(String.Format(" Number of Frames Observed: {0}", benchmark.FrameTimes.Count)); lines.Add(String.Empty); lines.Add(String.Format(" Min. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", benchmark.MinimumFrameTime, ProductionCalculator.GetPPD(benchmark.MinimumFrameTime, protein, calculateBonus.IsEnabled()))); lines.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", benchmark.AverageFrameTime, ProductionCalculator.GetPPD(benchmark.AverageFrameTime, protein, calculateBonus.IsEnabled()))); if (unitInfoModel != null) { lines.Add(String.Format(" Cur. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", unitInfoModel.GetFrameTime(PpdCalculationType.LastFrame), unitInfoModel.GetPPD(status, PpdCalculationType.LastFrame, calculateBonus))); lines.Add(String.Format(" R3F. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", unitInfoModel.GetFrameTime(PpdCalculationType.LastThreeFrames), unitInfoModel.GetPPD(status, PpdCalculationType.LastThreeFrames, calculateBonus))); lines.Add(String.Format(" All Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", unitInfoModel.GetFrameTime(PpdCalculationType.AllFrames), unitInfoModel.GetPPD(status, PpdCalculationType.AllFrames, calculateBonus))); lines.Add(String.Format(" Eff. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD", unitInfoModel.GetFrameTime(PpdCalculationType.EffectiveRate), unitInfoModel.GetPPD(status, PpdCalculationType.EffectiveRate, calculateBonus))); } lines.Add(String.Empty); }
public void GetPPD_Test2() { var protein = new Protein { Credit = 700, PreferredDays = 3, MaximumDays = 5, KFactor = 26.4 }; Assert.AreEqual(39307.35, ProductionCalculator.GetPPD(TimeSpan.FromMinutes(5), protein, true), 0.01); }
public void GetPPD_Test1() { var protein = new Protein { Credit = 500 }; Assert.AreEqual(1440.0, ProductionCalculator.GetPPD(TimeSpan.FromMinutes(5), protein)); }
public override object Invoke(object[] args) { Debug.Assert(args.Length == 9); if (args.Any(x => x == null || Convert.IsDBNull(x))) { return(0.0); } var frameTime = TimeSpan.FromSeconds((long)args[0]); // unbox then cast to int var frames = (int)((long)args[1]); var baseCredit = (double)args[2]; var kFactor = (double)args[3]; var preferredDays = (double)args[4]; var maximumDays = (double)args[5]; DateTime downloadDateTime; DateTime.TryParseExact((string)args[6], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out downloadDateTime); DateTime completionDateTime; DateTime.TryParseExact((string)args[7], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out completionDateTime); var calcOption = (long)args[8]; TimeSpan unitTime = TimeSpan.Zero; switch (BonusCalculation) { case BonusCalculationType.FrameTime: unitTime = TimeSpan.FromSeconds(frameTime.TotalSeconds * frames); break; case BonusCalculationType.DownloadTime: unitTime = completionDateTime.Subtract(downloadDateTime); break; } if (calcOption != 0) { return(ProductionCalculator.GetCredit(baseCredit, kFactor, preferredDays, maximumDays, unitTime)); } return(ProductionCalculator.GetPPD(frameTime, frames, baseCredit, kFactor, preferredDays, maximumDays, unitTime)); }
public void GetPPD_Test3() { var protein = new Protein(); Assert.AreEqual(0.0, ProductionCalculator.GetPPD(TimeSpan.Zero, protein)); }
public void CreatePpdGraph(ZedGraphControl zg, IList <string> projectInfoLines, 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 (projectInfoLines.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 = ProductionCalculator.GetPPD(benchmark.MinimumFrameTime, protein, calculateBonus); averageFrameTimePPD = ProductionCalculator.GetPPD(benchmark.AverageFrameTime, protein, 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 < projectInfoLines.Count - 2; i++) { sb.Append(projectInfoLines[i]); sb.Append(" "); } sb.Append(projectInfoLines[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(); } }