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);
            var calculateBonusEnabled = calculateBonus.IsEnabled();

            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, GetPPD(benchmark.MinimumFrameTime, protein, calculateBonusEnabled)));
            lines.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                    benchmark.AverageFrameTime, GetPPD(benchmark.AverageFrameTime, protein, calculateBonusEnabled)));

            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);
        }
예제 #2
0
 protected override double[] GetYPoints(Protein protein, ProteinBenchmark benchmark)
 {
     return(new[]
     {
         benchmark.MinimumFrameTime.TotalSeconds,
         benchmark.AverageFrameTime.TotalSeconds
     });
 }
예제 #3
0
        private SlotModel FindRunningSlot(ProteinBenchmark benchmark)
        {
            if (ClientConfiguration is null)
            {
                return(null);
            }

            var slot = ClientConfiguration.GetSlots().FirstOrDefault(x =>
                                                                     x.SlotIdentifier.Equals(benchmark.SlotIdentifier) &&
                                                                     x.WorkUnitModel.BenchmarkIdentifier.Equals(benchmark.BenchmarkIdentifier));

            return(slot != null && slot.Status.IsRunning() ? slot : null);
        }
예제 #4
0
 protected static string GetSlotNameAndProcessor(ProteinBenchmark benchmark, Protein protein)
 {
     if (protein != null)
     {
         var slotType            = ConvertToSlotType.FromCoreName(protein.Core);
         var processorAndThreads = benchmark.BenchmarkIdentifier.ToProcessorAndThreadsString(slotType);
         if (!String.IsNullOrWhiteSpace(processorAndThreads))
         {
             return(String.Join(" / ", benchmark.SlotIdentifier.Name, processorAndThreads));
         }
     }
     return(benchmark.SlotIdentifier.Name);
 }
예제 #5
0
        protected override double[] GetYPoints(Protein protein, ProteinBenchmark benchmark)
        {
            int  decimalPlaces  = Preferences.Get <int>(Preference.DecimalPlaces);
            bool calculateBonus = Preferences.Get <BonusCalculation>(Preference.BonusCalculation) != BonusCalculation.None;

            double minimumFrameTimePPD = GetPPD(protein, benchmark.MinimumFrameTime, calculateBonus);
            double averageFrameTimePPD = GetPPD(protein, benchmark.AverageFrameTime, calculateBonus);

            return(new[]
            {
                Math.Round(minimumFrameTimePPD, decimalPlaces),
                Math.Round(averageFrameTimePPD, decimalPlaces)
            });
        }
예제 #6
0
        private static void ValidateTestBenchmarkData(List <ProteinBenchmark> list)
        {
            for (int i = 0; i < 10; i++)
            {
                ProteinBenchmark benchmark = list[i];
                Assert.AreEqual("TestOwner", benchmark.SlotIdentifier.Name);
                Assert.AreEqual("TestOwner", benchmark.SlotIdentifier.ClientIdentifier.Name);
                Assert.AreEqual("TestOwner", benchmark.SourceName);
                Assert.AreEqual("TestPath", benchmark.SlotIdentifier.ClientIdentifier.ToServerPortString());
                Assert.AreEqual("TestPath", benchmark.SourcePath);
                Assert.AreEqual(-1, benchmark.SlotIdentifier.SlotID);
                Assert.AreEqual(-1, benchmark.SourceSlotID);
                Assert.AreEqual(100 + i, benchmark.ProjectID);

                int index = 0;
                for (int j = 5; j > 0; j--)
                {
                    Assert.AreEqual(TimeSpan.FromMinutes(j), benchmark.FrameTimes[index].Duration);
                    index++;
                }
            }

            for (int i = 10; i < 20; i++)
            {
                ProteinBenchmark benchmark = list[i];
                Assert.AreEqual(String.Format(CultureInfo.InvariantCulture, "TestOwner2 Slot {0:00}", (i - 10)), benchmark.SlotIdentifier.Name);
                Assert.AreEqual("TestOwner2", benchmark.SlotIdentifier.ClientIdentifier.Name);
                Assert.AreEqual("TestOwner2", benchmark.SourceName);
                Assert.AreEqual("TestPath2", benchmark.SlotIdentifier.ClientIdentifier.ToServerPortString());
                Assert.AreEqual("TestPath2", benchmark.SourcePath);
                Assert.AreEqual(GuidFromInt32(i), benchmark.SlotIdentifier.ClientIdentifier.Guid);
                Assert.AreEqual(GuidFromInt32(i), benchmark.SourceGuid);
                Assert.AreEqual(i - 10, benchmark.SlotIdentifier.SlotID);
                Assert.AreEqual(i - 10, benchmark.SourceSlotID);
                Assert.AreEqual(200 + i, benchmark.ProjectID);

                int index = 0;
                for (int j = 5; j > 0; j--)
                {
                    Assert.AreEqual(TimeSpan.FromMinutes(j + 10), benchmark.FrameTimes[index].Duration);
                    index++;
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Time per frame (TPF) of the unit
        /// </summary>
        public TimeSpan GetFrameTime(PpdCalculationType calculationType)
        {
            int rawTime = GetRawTime(calculationType);

            if (rawTime != 0)
            {
                return(TimeSpan.FromSeconds(rawTime));
            }

            // Issue 79 - no benchmark container is available to merged display instances
            if (_benchmarkService != null)
            {
                ProteinBenchmark benchmark = _benchmarkService.GetBenchmark(UnitInfoData);
                if (benchmark != null)
                {
                    return(benchmark.AverageFrameTime);
                }
            }
            return(TimeSpan.Zero);
        }
예제 #8
0
        private static List <ProteinBenchmark> CreateTestBenchmarkData()
        {
            var list = new List <ProteinBenchmark>();

            for (int i = 0; i < 10; i++)
            {
                var benchmark = new ProteinBenchmark
                {
                    SourceName = "TestOwner",
                    SourcePath = "TestPath",
                    ProjectID  = 100 + i
                };

                for (int j = 1; j < 6; j++)
                {
                    benchmark.AddFrameTime(TimeSpan.FromMinutes(j));
                }
                list.Add(benchmark);
            }

            for (int i = 10; i < 20; i++)
            {
                var benchmark = new ProteinBenchmark
                {
                    SourceName   = "TestOwner2",
                    SourcePath   = "TestPath2",
                    SourceGuid   = GuidFromInt32(i),
                    SourceSlotID = i - 10,
                    ProjectID    = 200 + i
                };

                for (int j = 1; j < 6; j++)
                {
                    benchmark.AddFrameTime(TimeSpan.FromMinutes(j + 10));
                }
                list.Add(benchmark);
            }

            return(list);
        }
예제 #9
0
        private static List <ProteinBenchmark> CreateTestList()
        {
            var list = new List <ProteinBenchmark>();

            for (int i = 0; i < 10; i++)
            {
                var benchmark = new ProteinBenchmark
                {
                    OwningClientName = "TestOwner",
                    OwningClientPath = "TestPath",
                    ProjectID        = 100 + i
                };

                for (int j = 1; j < 6; j++)
                {
                    benchmark.SetFrameDuration(TimeSpan.FromMinutes(j));
                }
                list.Add(benchmark);
            }

            for (int i = 10; i < 20; i++)
            {
                var benchmark = new ProteinBenchmark
                {
                    OwningClientName = "TestOwner2",
                    OwningClientPath = "TestPath2",
                    OwningSlotId     = i - 10,
                    ProjectID        = 200 + i
                };

                for (int j = 1; j < 6; j++)
                {
                    benchmark.SetFrameDuration(TimeSpan.FromMinutes(j + 10));
                }
                list.Add(benchmark);
            }

            return(list);
        }
      private static List<ProteinBenchmark> CreateTestList()
      {
         var list = new List<ProteinBenchmark>();
         for (int i = 0; i < 10; i++)
         {
            var benchmark = new ProteinBenchmark
                            {
                               OwningClientName = "TestOwner",
                               OwningClientPath = "TestPath",
                               ProjectID = 100 + i
                            };
            
            for (int j = 1; j < 6; j++)
            {
               benchmark.SetFrameTime(TimeSpan.FromMinutes(j));
            }
            list.Add(benchmark);
         }

         for (int i = 10; i < 20; i++)
         {
            var benchmark = new ProteinBenchmark
            {
               OwningClientName = "TestOwner2",
               OwningClientPath = "TestPath2",
               OwningSlotId = i - 10,
               ProjectID = 200 + i
            };

            for (int j = 1; j < 6; j++)
            {
               benchmark.SetFrameTime(TimeSpan.FromMinutes(j + 10));
            }
            list.Add(benchmark);
         }

         return list;
      }
예제 #11
0
        private static void ValidateTestList(IList <ProteinBenchmark> list)
        {
            for (int i = 0; i < 10; i++)
            {
                ProteinBenchmark benchmark = list[i];
                Assert.AreEqual("TestOwner", benchmark.OwningSlotName);
                Assert.AreEqual("TestOwner", benchmark.OwningClientName);
                Assert.AreEqual("TestPath", benchmark.OwningClientPath);
                Assert.AreEqual(-1, benchmark.OwningSlotId);
                Assert.AreEqual(100 + i, benchmark.ProjectID);

                int index = 0;
                for (int j = 5; j > 0; j--)
                {
                    Assert.AreEqual(TimeSpan.FromMinutes(j), benchmark.FrameTimes[index].Duration);
                    index++;
                }
            }

            for (int i = 10; i < 20; i++)
            {
                ProteinBenchmark benchmark = list[i];
                Assert.AreEqual(String.Format(CultureInfo.InvariantCulture, "TestOwner2 Slot {0:00}", (i - 10)), benchmark.OwningSlotName);
                Assert.AreEqual("TestOwner2", benchmark.OwningClientName);
                Assert.AreEqual("TestPath2", benchmark.OwningClientPath);
                Assert.AreEqual(i - 10, benchmark.OwningSlotId);
                Assert.AreEqual(200 + i, benchmark.ProjectID);

                int index = 0;
                for (int j = 5; j > 0; j--)
                {
                    Assert.AreEqual(TimeSpan.FromMinutes(j + 10), benchmark.FrameTimes[index].Duration);
                    index++;
                }
            }
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtBenchmarks.Text = String.Empty;
            int     projectId = (int)listBox1.SelectedItem;
            Protein protein   = _proteinService.Get(projectId);

            if (protein == null)
            {
                Logger.WarnFormat("Could not find Project {0}.", projectId);
            }

            var projectInfoLines = new List <string>();

            PopulateProteinInformation(protein, projectInfoLines);

            List <ProteinBenchmark> list = _benchmarkService.GetBenchmarks(_currentSlotIdentifier, projectId).ToList();

            list.Sort((benchmark1, benchmark2) => benchmark1.OwningSlotName.CompareTo(benchmark2.OwningSlotName));

            var benchmarkInfoLines = new List <string>(projectInfoLines);

            foreach (ProteinBenchmark benchmark in list)
            {
                UnitInfoModel unitInfoModel = null;
                SlotStatus    status        = SlotStatus.Unknown;

                var slotModel = _clientConfiguration.Slots.FirstOrDefault(x =>
                                                                          x.Name == benchmark.OwningSlotName &&
                                                                          x.Settings.DataPath() == benchmark.OwningClientPath &&
                                                                          x.UnitInfoModel.UnitInfoData.ProjectID == benchmark.ProjectID);
                if (slotModel != null && slotModel.ProductionValuesOk)
                {
                    unitInfoModel = slotModel.UnitInfoModel;
                    status        = slotModel.Status;
                }
                PopulateBenchmarkInformation(protein, benchmark, unitInfoModel, status, _prefs.GetPpdFormatString(), benchmarkInfoLines);
            }

            UpdateBenchmarkText(benchmarkInfoLines);

            tabControl1.SuspendLayout();

            int clientsPerGraph = _prefs.Get <int>(Preference.BenchmarksClientsPerGraph);

            SetupGraphTabs(list.Count, clientsPerGraph);

            int tabIndex = 1;

            if (GraphLayoutType.Equals(GraphLayoutType.ClientsPerGraph))
            {
                int lastDisplayed = 0;
                for (int i = 1; i < list.Count; i++)
                {
                    if (i % clientsPerGraph == 0)
                    {
                        var benchmarks = new ProteinBenchmark[clientsPerGraph];
                        list.CopyTo(lastDisplayed, benchmarks, 0, clientsPerGraph);
                        DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                        tabIndex++;
                        lastDisplayed = i;
                    }
                }

                if (lastDisplayed < list.Count)
                {
                    var benchmarks = new ProteinBenchmark[list.Count - lastDisplayed];
                    list.CopyTo(lastDisplayed, benchmarks, 0, list.Count - lastDisplayed);
                    DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                }
            }
            else
            {
                DrawGraphs(tabIndex, projectInfoLines, list, protein);
            }

            tabControl1.ResumeLayout(true);
        }
예제 #13
0
 internal static ProteinBenchmarkSlotIdentifier ToSlotIdentifier(this ProteinBenchmark proteinBenchmark)
 {
     return(new ProteinBenchmarkSlotIdentifier(proteinBenchmark.OwningSlotName, proteinBenchmark.OwningClientPath));
 }
예제 #14
0
        private static IEnumerable <string> EnumerateBenchmarkInformation(Protein protein, ProteinBenchmark benchmark, string numberFormat, bool calculateBonus)
        {
            yield return($" Name: {benchmark.SlotIdentifier.Name}");

            yield return($" Path: {benchmark.SlotIdentifier.ClientIdentifier.ToServerPortString()}");

            if (benchmark.BenchmarkIdentifier.HasProcessor)
            {
                var slotType = ConvertToSlotType.FromCoreName(protein.Core);
                yield return($" Proc: {benchmark.BenchmarkIdentifier.ToProcessorAndThreadsString(slotType)}");
            }
            yield return($" Number of Frames Observed: {benchmark.FrameTimes.Count}");

            yield return(String.Empty);

            yield return(String.Format(CultureInfo.InvariantCulture, " Min. Time / Frame : {0} - {1} PPD",
                                       benchmark.MinimumFrameTime, GetPPD(protein, benchmark.MinimumFrameTime, calculateBonus).ToString(numberFormat)));

            yield return(String.Format(CultureInfo.InvariantCulture, " Avg. Time / Frame : {0} - {1} PPD",
                                       benchmark.AverageFrameTime, GetPPD(protein, benchmark.AverageFrameTime, calculateBonus).ToString(numberFormat)));
        }
예제 #15
0
 protected abstract double[] GetYPoints(Protein protein, ProteinBenchmark benchmark);
예제 #16
0
      /// <summary>
      /// Return Multi-Line String (Array)
      /// </summary>
      private IEnumerable<string> ToMultiLineString(ProteinBenchmark benchmark, UnitInfoModel unitInfoModel, bool valuesOk, SlotStatus status, string ppdFormatString)
      {
         var output = new List<string>(12);

         Protein protein = _proteinService.Get(benchmark.ProjectID);
         if (protein != null)
         {
            var calculateBonus = _prefs.Get<BonusCalculationType>(Preference.BonusCalculation);

            output.Add(String.Empty);
            output.Add(String.Format(" Name: {0}", benchmark.OwningSlotName));
            output.Add(String.Format(" Path: {0}", benchmark.OwningClientPath));
            output.Add(String.Format(" Number of Frames Observed: {0}", benchmark.FrameTimes.Count));
            output.Add(String.Empty);
            output.Add(String.Format(" Min. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.MinimumFrameTime, ProductionCalculator.GetPPD(benchmark.MinimumFrameTime, protein, calculateBonus.IsEnabled())));
            output.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
               benchmark.AverageFrameTime, ProductionCalculator.GetPPD(benchmark.AverageFrameTime, protein, calculateBonus.IsEnabled())));

            if (unitInfoModel != null && unitInfoModel.UnitInfoData.ProjectID.Equals(protein.ProjectNumber) && valuesOk)
            {
               output.Add(String.Format(" Cur. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.LastFrame), unitInfoModel.GetPPD(status, PpdCalculationType.LastFrame, calculateBonus)));
               output.Add(String.Format(" R3F. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.LastThreeFrames), unitInfoModel.GetPPD(status, PpdCalculationType.LastThreeFrames, calculateBonus)));
               output.Add(String.Format(" All  Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.AllFrames), unitInfoModel.GetPPD(status, PpdCalculationType.AllFrames, calculateBonus)));
               output.Add(String.Format(" Eff. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                  unitInfoModel.GetFrameTime(PpdCalculationType.EffectiveRate), unitInfoModel.GetPPD(status, PpdCalculationType.EffectiveRate, calculateBonus)));
            }

            output.Add(String.Empty);
         }
         else
         {
            _logger.WarnFormat("Could not find Project {0}.", benchmark.ProjectID);
         }

         return output.ToArray();
      }
예제 #17
0
      private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
         txtBenchmarks.Text = String.Empty;
         int projectId = (int)listBox1.SelectedItem;

         string[] lines = UpdateProteinInformation(projectId);

         UpdateBenchmarkText(lines);

         List<ProteinBenchmark> list = _benchmarkCollection.GetBenchmarks(_currentBenchmarkClient, projectId).ToList();
         list.Sort((benchmark1, benchmark2) => benchmark1.OwningSlotName.CompareTo(benchmark2.OwningSlotName));
         Protein protein = _proteinService.Get(projectId);

         foreach (ProteinBenchmark benchmark in list)
         {
            UnitInfoModel unit = null;
            bool valuesOk = false;
            SlotStatus status = SlotStatus.Unknown;

            ProteinBenchmark benchmark1 = benchmark;
            var slotModel = _clientConfiguration.Slots.FirstOrDefault(x => x.Name.Equals(benchmark1.OwningSlotName));
            if (slotModel != null && slotModel.Owns(benchmark))
            {
               unit = slotModel.UnitInfoModel;
               valuesOk = slotModel.ProductionValuesOk;
               status = slotModel.Status;
            }
            UpdateBenchmarkText(ToMultiLineString(benchmark, unit, valuesOk, status, _prefs.GetPpdFormatString()));
         }

         tabControl1.SuspendLayout();

         int clientsPerGraph = _prefs.Get<int>(Preference.BenchmarksClientsPerGraph);
         SetupGraphTabs(list.Count, clientsPerGraph);

         int tabIndex = 1;
         if (GraphLayoutType.Equals(GraphLayoutType.ClientsPerGraph))
         {
            int lastDisplayed = 0;
            for (int i = 1; i < list.Count; i++)
            {
               if (i % clientsPerGraph == 0)
               {
                  var benchmarks = new ProteinBenchmark[clientsPerGraph];
                  list.CopyTo(lastDisplayed, benchmarks, 0, clientsPerGraph);
                  DrawGraphs(tabIndex, lines, benchmarks, protein);
                  tabIndex++;
                  lastDisplayed = i;
               }
            }

            if (lastDisplayed < list.Count)
            {
               var benchmarks = new ProteinBenchmark[list.Count - lastDisplayed];
               list.CopyTo(lastDisplayed, benchmarks, 0, list.Count - lastDisplayed);
               DrawGraphs(tabIndex, lines, benchmarks, protein);
            }
         }
         else
         {
            DrawGraphs(tabIndex, lines, list, protein);
         }

         tabControl1.ResumeLayout(true);
      }