public void Dispose() { PerformanceData performanceData = PerformanceContext.Current.TakeSnapshot(false) - this.startSnapshot; this.logger.Log(this.marker, "LdapLatency", performanceData.Latency); this.logger.Log(this.marker, "LdapCount", performanceData.Count); }
public void Dispose() { PerformanceData performanceData = RpcDataProvider.Instance.TakeSnapshot(false) - this.startSnapshot; this.logger.Log(this.marker, "StoreRpcLatency", performanceData.Latency); this.logger.Log(this.marker, "StoreRpcCount", performanceData.Count); }
public void PerformerUpdate(SigActorsData actors, SigPerfData data) { if (actors == null) { return; } Dictionary <string, BmpLocalPerformer> performerNames = this.GetPerformerNames(); foreach (ActorData ad in actors.currentActors.Values.ToList()) { this.PerformersInvoke(t => { if (performerNames.ContainsKey(ad.name)) { // Needs name cache because they might zone in or out uint perfId = ad.perfid / 2; if (perfId >= 0 && perfId < 99) { if (!data.Performances.ContainsKey(perfId)) { return; } PerformanceData pdata = data.Performances[perfId]; Console.WriteLine(string.Format("{0}: {1}", ad.name, pdata.IsReady())); performerNames[ad.name].PerformanceUp = pdata.IsReady(); } } }); } }
private void AddPerformanceData(XmlDocument xml, XmlElement results) { if (this.ContainsKey(typeof(PerformanceData)) == false) { return; } PerformanceData r = (PerformanceData)this[typeof(PerformanceData)]; XmlElement b = xml.CreateElement("performance"); results.AppendChild(b); b.SetAttribute("xut", r.MaxUserTime.ToString()); b.SetAttribute("xpt", r.MaxProcessorTime.ToString()); b.SetAttribute("xws", r.MaxWorkingSet.ToString()); b.SetAttribute("xpws", r.MaxPrivateWorkingSet.ToString()); b.SetAttribute("nut", r.MinUserTime.ToString()); b.SetAttribute("npt", r.MinProcessorTime.ToString()); b.SetAttribute("nws", r.MinWorkingSet.ToString()); b.SetAttribute("npws", r.MinPrivateWorkingSet.ToString()); XmlElement t = null; foreach (PerformanceState ps in r) { t = xml.CreateElement("p"); t.SetAttribute("ts", ps.TimeStamp.ToString()); t.SetAttribute("ut", ps.UserTime.ToString()); t.SetAttribute("pt", ps.ProcessorTime.ToString()); t.SetAttribute("ws", ps.WorkingSet.ToString()); t.SetAttribute("pws", ps.PrivateWorkingSet.ToString()); b.AppendChild(t); } }
private static Task WriteAsync(EventHubClient client, PerformanceData value, CancellationToken cancellationToken) { var content = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)); var data = new EventData(content); return(client.SendAsync(data)); }
public override void Execute(Guid application) { try { var query = new LogQuery() { ApplicationIdentifier = application, From = DateTime.UtcNow.AddHours(-24), To = DateTime.UtcNow, Top = 5000 }; var data = new PerformanceData() { Occurrences = logCore.SelectOccurrences(query), GeneratedOn = DateTime.UtcNow, }; foreach (var occurrence in data.Occurrences) { occurrence.Token = null; } var objectId = LogCore.Performance1DaysFormat.FormatWithCulture(application.ToAscii85().GetHexMD5()); blob.Save(objectId, data); } catch (Exception ex) { logCore.Log(ex, EventTypes.Critical, 99999); } }
public ActionResult Create(PerformanceData performanceData) { if (performanceData.FormId == 0 || performanceData.Evaluation.ID == 0 || performanceData.Answers.Equals(0) || performanceData.Employee.Id == 0) { performanceData.Evaluations = _context.Evaluations.ToList(); performanceData.Employees = _context.Employees.ToList(); performanceData.Forms = _context.Forms.ToList(); if (performanceData.FormId != 0) { performanceData.Questions = performanceData.GetFormQuestions(performanceData.FormId); } return(View("Create", performanceData)); } var performance = new Performance() { FormID = performanceData.FormId, EmployeeID = performanceData.Employee.Id, EvaluationID = performanceData.Evaluation.ID, DateEvaluated = DateTime.Now, }; performance.OveralRating = OverallRatingCalculate(performanceData.Answers); if (_context.Performances.Any(p => p.EmployeeID == performance.EmployeeID && p.EvaluationID == performance.EvaluationID)) { performanceData.ExistingPerformance = true; performanceData.Forms = _context.Forms; performanceData.Employees = _context.Employees; performanceData.Evaluations = _context.Evaluations.ToList(); performanceData.Questions = performanceData.GetFormQuestions(performanceData.FormId); return(View("Create", performanceData)); } _context.Performances.Add(performance); _context.SaveChanges(); for (int i = 0; i < performanceData.Questions.Count; i++) { performanceData.Answers[i].QuestionID = performanceData.Questions[i].ID; } foreach (var answer in performanceData.Answers) { answer.PerformanceID = performance.ID; _context.Answers.Add(answer); } _context.SaveChanges(); return(RedirectToAction("Index", "Evaluations")); }
/// <summary> /// Publish performance data to the server. /// </summary> /// <param name="data"></param> internal void PublishPerformance(PerformanceData data) { if (!Faulted) { _sender.PublishPerformance(data); } }
public void PublishPerformance(PerformanceData data) { if (!Faulted) { _proxy.ReportPerformanceAsync(data); } }
public override void OnEntry(MethodExecutionArgs args) { var performanceData = new PerformanceData(); performanceData.Start(); args.MethodExecutionTag = performanceData; }
// Get performance list. public BindingList <PerformanceData> GetPerfList() { using (SqlConnection conn = new SqlConnection(conStr)) { conn.Open(); BindingList <PerformanceData> list = new BindingList <PerformanceData>(); string sql = "Execute GetPerfList"; Console.WriteLine(sql); using (SqlCommand command = new SqlCommand(sql, conn)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { PerformanceData project = new PerformanceData { PerformanceID = reader.GetInt32(0), EmployeeID = reader.GetInt32(1), ProjectID = reader.GetInt32(2), WorkingDate = reader.GetDateTime(3), WorkingHour = reader.GetDouble(4), WorkingDetail = reader.GetString(6), EmployeeName = reader.GetString(7), ProjectName = reader.GetString(8) }; list.Add(project); } } } return(list); } }
private void WorkerPerformance_DoWork(object sender, DoWorkEventArgs e) { // Executes when RunWorkerAsync() is called List <Performance> dataReceived = new PerformanceData().GetPerformanceList(); //change for other all e.Result = dataReceived; }
internal override void ProcessMappingsFromRowValues(RowValues values) { AdExtensionIdToEntityIdAssociation = new AdExtensionIdToEntityIdAssociation(); values.ConvertToEntity(this, Mappings); PerformanceData = PerformanceData.ReadFromRowValuesOrNull(values); }
private void CreatePerformanceGraph(string instanceName, string counterName) { var perfData = new PerformanceData(new PerformanceCounter("Process", counterName, instanceName)); var filteredData = new FilteringDataSource<PerformanceInfo>(perfData, new MaxSizeFilter()); var dataSource = new EnumerableDataSource<PerformanceInfo>(filteredData); dataSource.SetXMapping(pi => (pi.Time.TimeOfDay.TotalSeconds - (_currentTotal == 0 ? _currentTotal = pi.Time.TimeOfDay.TotalSeconds : _currentTotal))); dataSource.SetYMapping(pi => Proc.GetCpuValue(pi.Value)); Plotter.AddLineGraph(dataSource, 0.8, string.Format("{0} - {1}", counterName, instanceName)); }
public virtual bool Stop() { if (!_stopped && Id > 0) { _stopped = true; return(PerformanceData.Touch(Id)); } return(false); }
internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData) { this.ConvertToValues(values, Mappings); if (!excludeReadonlyData) { PerformanceData.WriteToRowValuesIfNotNull(PerformanceData, values); } }
public void SetToAverage(List <CandidateAgentData> leaderboard) { var inverseCount = 1f / (leaderboard.Count - 1); candidateGenome.bodyGenome.coreGenome.SetToAverage(leaderboard, inverseCount); candidateGenome.bodyGenome.appearanceGenome.SetToAverage(leaderboard, inverseCount); performanceData = new PerformanceData(leaderboard, inverseCount); //SetPerformanceDataToAverage(leaderboard, inverseCount); }
public void Dispose() { for (int i = 0; i < ActiveManagerPerformanceData.Providers.Length; i++) { PerformanceData pd = ActiveManagerPerformanceData.Providers[i].Provider.TakeSnapshot(false); PerformanceData performanceData = pd - this.initialSnapshots[i]; this.logger.Log(this.marker, ActiveManagerPerformanceData.Providers[i].LogCount, performanceData.Count); this.logger.Log(this.marker, ActiveManagerPerformanceData.Providers[i].LogLatency, performanceData.Latency); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="Microsoft.Rest.ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (PerformanceData != null) { PerformanceData.Validate(); } if (Video != null) { Video.Validate(); } }
internal override void ProcessMappingsToRowValues(RowValues values, bool excludeReadonlyData) { ValidatePropertyNotNull(AdExtensionIdToEntityIdAssociation, "AdExtensionIdToEntityIdAssociation"); this.ConvertToValues(values, Mappings); if (!excludeReadonlyData) { PerformanceData.WriteToRowValuesIfNotNull(PerformanceData, values); } }
private LineGraph CreateFilteredPerformanceGraph(string categoryName, string counterName, string instanceName, IFilter<PerformanceInfo> filter) { PerformanceData data = new PerformanceData(new PerformanceCounter(categoryName, counterName, instanceName)); var filteredData = new FilteringDataSource<PerformanceInfo>(data, filter); var ds = new EnumerableDataSource<PerformanceInfo>(filteredData); ds.SetXMapping(pi => pi.Time.TimeOfDay.TotalSeconds); ds.SetYMapping(pi => pi.Value); LineGraph chart = plotter.AddLineGraph(ds, 2.0, String.Format("{0} - {1}", categoryName, counterName)); return chart; }
public static void Report(PerformanceData data) { foreach (IPerformanceLogger logger in _loggers) { try { logger.Report(data.ClientIp, data); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex); } } }
public void Stop() { this.EnforceInternalState(ContactsUploaderPerformanceTracker.InternalState.Started, "Stop"); this.stopwatch.Stop(); ThreadTimes fromCurrentThread = ThreadTimes.GetFromCurrentThread(); PerformanceData pd = RpcDataProvider.Instance.TakeSnapshot(false); this.internalState = ContactsUploaderPerformanceTracker.InternalState.Stopped; this.cpuTime += fromCurrentThread.Kernel - this.startThreadTimes.Kernel + (fromCurrentThread.User - this.startThreadTimes.User); PerformanceData performanceData = pd - this.startStorePerformanceData; this.storeRpcLatency += performanceData.Latency; this.storeRpcCount += (int)performanceData.Count; }
public SampleMultiPointListDemo() : base("A demonstration that uses the SampleMultiPointList " + "class, which is a custom class that demonstrates the implementation of the IPointList " + "interface. This allows you to store your data in a custom structure, class, database, etc., " + "and to use this data directly within ZedGraph. In this particular demo, that data are stored " + "in memory only once, but they are used for multiple curves.", "SampleMultiPointList (IPointList) Demo", DemoType.Line, DemoType.Special) { GraphPane myPane = base.GraphPane; // Set the titles and axis labels myPane.Title.Text = "SampleMultiPointList (IPointList) Demo"; myPane.XAxis.Title.Text = "Time, seconds"; myPane.YAxis.Title.Text = "Distance (m), or Velocity (m/s)"; // Create a new SampleMultiPointList (see SampleMultiPointList.cs for details) SampleMultiPointList myList = new SampleMultiPointList(); // For the first list, specify that the Y data to be plotted will be the distance myList.YData = PerfDataType.Distance; // note how it does not matter that we created the second list before actually // adding the data -- this is because the cloned list shares data with the // original SampleMultiPointList myList2 = new SampleMultiPointList(myList); // For the second list, specify that the Y data to be plotted will be the velocity myList2.YData = PerfDataType.Velocity; // Populate the dataset using some calculated values for (int i = 0; i < 20; i++) { double time = (double)i; double acceleration = 1.0; double velocity = acceleration * time; double distance = acceleration * time * time / 2.0; PerformanceData perfData = new PerformanceData(time, distance, velocity, acceleration); myList.Add(perfData); } // Add two curves to the graph myPane.AddCurve("Distance", myList, Color.Blue); myPane.AddCurve("Velocity", myList2, Color.Red); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0F); base.ZedGraphControl.AxisChange(); }
public async void GetValidatorPerformance() { var result = await _apiInstance.ApiV1ValidatorIndexOrPubkeyPerformanceGetAsync(ValidatorPubKey); try { this._performance = JsonConvert.DeserializeObject <Performance>(result).Data; } catch (Exception e) { //this handles bad server response they didn't have proper json format when no data is present } UpdateUi(); }
public void Test() { var logger = new PerformanceLogger <PerformanceData>("unittests"); var rnd = new Random(); var dataValue = new [] { "Action 1", "Action 2", "Action 3" }; foreach (var i in Enumerable.Range(0, 10)) { var performanceData = new PerformanceData(dataValue[i % 3], (float)rnd.NextDouble()); logger.Log(performanceData); Thread.Sleep(rnd.Next(0, 10)); } Thread.Sleep(100); }
public static PerformanceData EndTrace(string uri, TraceServer traceServerReader) { PerformanceData perf = new PerformanceData(uri); traceServerReader.Stop(); while (traceServerReader.Read()) { string ApplicationName = traceServerReader.GetString(2); if (ApplicationName == null) ApplicationName = string.Empty; if (ApplicationName == "SQL Management") continue; if (ApplicationName == "Microsoft SQL Server Management Studio") continue; if (ApplicationName.StartsWith("SQL Server Profiler")) continue; //0: EventClass //1: TextData //2: ApplicationName //3: NTUserName //4: LoginName //5: CPU //6: Reads //7: Writes //8: Duration //9: ClientProcessID //10: SPID //11: StartTime //12: EndTime //13: BinaryData //string query = traceServerReader.GetString(1); //if (string.IsNullOrEmpty(query)) query = string.Empty; //if (query.StartsWith("exec sp_executesql N'")) query = query.Remove(0, 21); // if (query.Length > 64) query = query.Substring(0, 64); //Console.WriteLine("{0}: {1} -> {2} | CPU={3} | Duration={4}", nEventNum, // query, // traceServerReader.GetString(2), // traceServerReader.GetOrdinal("CPU"), // traceServerReader.GetOrdinal("Duration")); perf.Queries++; object duration = traceServerReader.GetValue(8); perf.TotalDuration += (duration == null ? 0 : (long)duration); } return perf; }
private List <PerformanceData> EnrichPerformance(List <Performance> performances, List <Play> plays) { var result = new List <PerformanceData>(); performances.ForEach(aPerformance => { var calculator = CreatePerformanceCalculatorData(aPerformance, PlayFor(aPerformance, plays)); var perf = new PerformanceData { Performance = calculator.Performance, Play = calculator.Play, Aumont = calculator.Aumont, VolumeCredits = calculator.VolumeCredits }; result.Add(perf); }); return(result); }
public CandidateAgentData(AgentGenome genome, int speciesID) { //Debug.Log("NewCandidateData: " + MasterGenomePool.nextCandidateIndex.ToString()); MasterGenomePool.nextCandidateIndex++; causeOfDeath = "Alive!"; candidateID = MasterGenomePool.nextCandidateIndex; this.speciesID = speciesID; candidateGenome = genome; numCompletedEvaluations = 0; //evaluationScoresList = new List<float>(); allEvaluationsComplete = false; isBeingEvaluated = false; //name = GenerateTempCritterName(); candidateEventDataList = new List <CandidateEventData>(); performanceData = new PerformanceData(); }
/// Initialize as average public PerformanceData(List <CandidateAgentData> leaderboard, float inverseCount) { PerformanceData self = new PerformanceData(); PerformanceData leader; // Sum the average leaderboard values foreach (var agent in leaderboard) { leader = agent.performanceData; self.totalDamageDealt += leader.totalDamageDealt; self.totalDamageTaken += leader.totalDamageTaken; self.totalFoodEatenCorpse += leader.totalFoodEatenCorpse; self.totalFoodEatenCreature += leader.totalFoodEatenCreature; self.totalFoodEatenEgg += leader.totalFoodEatenEgg; self.totalFoodEatenPlant += leader.totalFoodEatenPlant; self.totalFoodEatenZoop += leader.totalFoodEatenZoop; self.totalTicksAlive += leader.totalTicksAlive; self.totalTicksRested += leader.totalTicksRested; self.totalTimesAttacked += leader.totalTimesAttacked; self.totalTimesDashed += leader.totalTimesDashed; self.totalTimesDefended += leader.totalTimesDefended; self.totalTimesPregnant += leader.totalTimesPregnant; } // Multiply the result by the inverse of the leaderboard count for the average values self.totalDamageDealt *= inverseCount; self.totalDamageTaken *= inverseCount; self.totalFoodEatenCorpse *= inverseCount; self.totalFoodEatenCreature *= inverseCount; self.totalFoodEatenEgg *= inverseCount; self.totalFoodEatenPlant *= inverseCount; self.totalFoodEatenZoop *= inverseCount; self.totalTicksAlive *= inverseCount; self.totalTicksRested *= inverseCount; self.totalTimesAttacked *= inverseCount; self.totalTimesDashed *= inverseCount; self.totalTimesDefended *= inverseCount; self.totalTimesPregnant *= inverseCount; this = self; }
public ActionResult Create(PerformanceData performanceData) { var performance = new Performance() { FormID = performanceData.FormId, EmployeeID = performanceData.Employee.ID, EvaluationID = performanceData.Evaluation.ID, DateEvaluated = DateTime.Now, OveralRating = OverallRatingCalculate(performanceData.Answers) }; if (db.Performances.Any(p => p.EmployeeID == performance.EmployeeID && p.EvaluationID == performance.EvaluationID)) { performanceData.ExistingPerformance = true; performanceData.Forms = db.Forms; performanceData.Employees = db.Employees; performanceData.Evaluations = db.Evaluations.ToList(); performanceData.Questions = performanceData.GetFormQuestions(performanceData.FormId); return(View("Create", performanceData)); } db.Performances.Add(performance); db.SaveChanges(); for (int i = 0; i < performanceData.Questions.Count; i++) { performanceData.Answers[i].QuestionID = performanceData.Questions[i].ID; } foreach (var answer in performanceData.Answers) { answer.PerformanceID = performance.ID; db.Answers.Add(answer); } db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
// GET: Performances/Create public ActionResult Create(int?formId) { var viewModel = new PerformanceData() { Employees = db.Employees.ToList(), Evaluations = db.Evaluations.ToList(), Forms = db.Forms.ToList(), DateTime = DateTime.Now, }; if (formId != null) { viewModel.FormId = (int)formId; viewModel.Questions = viewModel.GetFormQuestions((int)formId); } return(View(viewModel)); }
public virtual void Stop() { this.EnforceInternalState(PerformanceTrackerBase.InternalState.Started, "Stop"); this.stopwatch.Stop(); ThreadTimes fromCurrentThread = ThreadTimes.GetFromCurrentThread(); PerformanceData pd = RpcDataProvider.Instance.TakeSnapshot(false); PerformanceData pd2 = PerformanceContext.Current.TakeSnapshot(false); this.internalState = PerformanceTrackerBase.InternalState.Stopped; this.CpuTime += fromCurrentThread.Kernel - this.startThreadTimes.Kernel + (fromCurrentThread.User - this.startThreadTimes.User); PerformanceData performanceData = pd - this.startStorePerformanceData; this.StoreRpcLatency += performanceData.Latency; this.StoreRpcCount += (int)performanceData.Count; PerformanceData performanceData2 = pd2 - this.startDirectoryPerformanceData; this.DirectoryLatency += performanceData2.Latency; this.DirectoryCount += (int)performanceData2.Count; this.CalculateStorePerformanceStatistics(); }
public static void Run() { //this class contains perfomance details, i.e. CPU usage PerformanceCounter cpuCounter; PerformanceCounter ramCounter; cpuCounter = new PerformanceCounter (); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; cpuCounter.NextValue (); //First value of CPU time is always zero so get value then wait a period for the next value System.Threading.Thread.Sleep (200); ramCounter = new PerformanceCounter ("Memory", "Available MBytes"); PerformanceData perfData = new PerformanceData(); INagMe register = (INagMe)XmlRpcProxyGen.Create(typeof(INagMe)); register.Url = Nagme.Globals.xmlrpcAddress(); while (Nagme.Globals.programRunning) { //Console.WriteLine (cpuCounter.NextValue () + "%"); //Console.WriteLine (ramCounter.NextValue () + "MB"); perfData.CPUUsage = (int)cpuCounter.NextValue(); perfData.RAMUsage = (int)ramCounter.NextValue(); if(register.updatePerformanceInfo(perfData, Nagme.Globals.DeviceID(), Nagme.Globals.DevicePassword())){ Console.WriteLine("Updated Performance Info"); }else{ Console.WriteLine("Failed Updating Performance Info"); } Console.WriteLine(""); System.Threading.Thread.Sleep (60000); } }
/// <summary> /// Updates the CPU utilization graph for the specified period, using the given /// performance data. /// </summary> /// <param name="fromDate">The starting date of the specified period</param> /// <param name="toDate">The ending date of the specified period</param> private void UpdateUtilizationGraphByCPU(DateTime fromDate, DateTime toDate, PerformanceData[] performanceDataItems) { int maxNodes = 0; double minLoad = 100; double peakLoad = 0; double maxCpuCapacity = 0; double minCpuCapacity = double.MaxValue; double maxMemoryCapacity = 0; double minMemoryCapacity = double.MaxValue; double maxStorageCapacity = 0; double minStorageCapacity = double.MaxValue; DateTime peakLoadTime = fromDate; DateTime minLoadTime = fromDate; DateTime currentTime = fromDate; DateTime incTime = currentTime; // [DK] NOTE: We divide the period specified by the parameters 'fromDate' // and 'toDate' into short timeslots. A timeslot is large // enough to encompass performance info from all nodes in the // network (i.e. it's larger than the Heartbeat interval). We // then determine the utilization for each of these timeslots. while (currentTime <= toDate) { // Record the start of the timeslot abscissaData.Add(currentTime); // Determine next timeslot incTime = currentTime.AddSeconds(ReportingUtil.ChartTimeGranularity); double cpuCapacity = 0; double memoryCapacity = 0; double storageCapacity = 0; IDictionary<string, Node> nodes = new Dictionary<string, Node>(); // Determine the utilization for the given timeslot by // finding all nodes and their average CPU usage within // this period. foreach (PerformanceData pdata in performanceDataItems) { if (pdata.TimeStamp >= currentTime) { if (pdata.TimeStamp <= incTime) { if (nodes.ContainsKey(pdata.NodeUri) == false) { Node newNode = new Node(pdata.NodeUri); newNode.CpuCapacity = pdata.CpuCapacity; newNode.MemoryCapacity = pdata.MemoryCapacity; newNode.StorageCapacity = pdata.StorageCapacity; nodes[pdata.NodeUri] = newNode; } Node node = nodes[pdata.NodeUri]; node.CpuUsage = (node.CpuUsage + pdata.CpuUsage) / 2; } else { break; } } } double totalCpuUsage = 0; double cpuUsagePercent = 0; // Compute utilization within this slot.. foreach (Node node in nodes.Values) { totalCpuUsage += node.CpuUsage; cpuCapacity += node.CpuCapacity; memoryCapacity += node.MemoryCapacity; storageCapacity += node.StorageCapacity; } if (nodes.Count != 0) { cpuUsagePercent = totalCpuUsage / nodes.Count; } ordinateData.Add(cpuUsagePercent); // Determine maximums for number of nodes, CPU, memory and storage // capacity for the current time slot.. maxNodes = Math.Max(maxNodes, nodes.Count); maxCpuCapacity = Math.Max(maxCpuCapacity, cpuCapacity); minCpuCapacity = Math.Min(minCpuCapacity, cpuCapacity); maxMemoryCapacity = Math.Max(maxMemoryCapacity, memoryCapacity); minMemoryCapacity = Math.Min(minMemoryCapacity, memoryCapacity); maxStorageCapacity = Math.Max(maxStorageCapacity, storageCapacity); minStorageCapacity = Math.Min(minStorageCapacity, storageCapacity); peakLoadTime = (cpuUsagePercent > peakLoad) ? currentTime : peakLoadTime; peakLoad = Math.Max(peakLoad, cpuUsagePercent); minLoadTime = (cpuUsagePercent < minLoad) ? currentTime : minLoadTime; minLoad = Math.Min(minLoad, cpuUsagePercent); // Move to the next timeslot currentTime = incTime; } }
/// <summary> /// Updates the CPU utilization graph for the specified period, using the given /// performance data. /// </summary> /// <param name="fromDate">The starting date of the specified period</param> /// <param name="toDate">The ending date of the specified period</param> private void UpdateUtilizationGraphByCPU_Nodes(DateTime fromDate, DateTime toDate, PerformanceData[] performanceDataItems) { DateTime peakLoadTime = fromDate; DateTime minLoadTime = fromDate; DateTime currentTime = fromDate; DateTime incTime = currentTime; // [DK] NOTE: We divide the period specified by the parameters 'fromDate' // and 'toDate' into short timeslots. A timeslot is large // enough to encompass performance info from all nodes in the // network (i.e. it's larger than the Heartbeat interval). We // then determine the utilization for each of these timeslots. while (currentTime <= toDate) { // Record the start of the timeslot abscissaData.Add(currentTime); // Determine next timeslot incTime = currentTime.AddSeconds(ReportingUtil.ChartTimeGranularity); IDictionary<string, Node> nodes = new Dictionary<string, Node>(); // Get all possible NodeUris foreach (PerformanceData pdata in performanceDataItems) { if (!ordinateDataForNodes.ContainsKey(pdata.NodeUri)) ordinateDataForNodes.Add(pdata.NodeUri, new List<double>()); } // Determine the utilization for the given timeslot by // finding all nodes and their average CPU usage within // this period. foreach (PerformanceData pdata in performanceDataItems) { if (pdata.TimeStamp >= currentTime) { if (pdata.TimeStamp <= incTime) { if (nodes.ContainsKey(pdata.NodeUri) == false) { Node newNode = new Node(pdata.NodeUri); newNode.CpuCapacity = pdata.CpuCapacity; newNode.MemoryCapacity = pdata.MemoryCapacity; newNode.StorageCapacity = pdata.StorageCapacity; nodes[pdata.NodeUri] = newNode; } Node node = nodes[pdata.NodeUri]; node.CpuUsage = (node.CpuUsage + pdata.CpuUsage) / 2; } else { break; } } } foreach (var ordinateDataNode in ordinateDataForNodes) { foreach (Node node in nodes.Values) { if (node.NodeUri == ordinateDataNode.Key) { ordinateDataNode.Value.Add(node.CpuUsage); break; } } ordinateDataNode.Value.Add(0); } // Move to the next timeslot currentTime = incTime; } }
/// <summary> /// Publish performance data to the server. /// </summary> /// <param name="data"></param> internal void PublishPerformance(PerformanceData data) { if (!Faulted) _sender.PublishPerformance(data); }
public static PerformanceData CreatePerformanceData(global::System.Collections.ObjectModel.ObservableCollection<int> performanceHistory, global::System.Collections.ObjectModel.ObservableCollection<global::System.DateTime> timeSamples, string timeFrame, string performanceCounter, global::System.Guid vMId, global::System.Guid stampId) { PerformanceData performanceData = new PerformanceData(); if ((performanceHistory == null)) { throw new global::System.ArgumentNullException("performanceHistory"); } performanceData.PerformanceHistory = performanceHistory; if ((timeSamples == null)) { throw new global::System.ArgumentNullException("timeSamples"); } performanceData.TimeSamples = timeSamples; performanceData.TimeFrame = timeFrame; performanceData.PerformanceCounter = performanceCounter; performanceData.VMId = vMId; performanceData.StampId = stampId; return performanceData; }
public void PublishPerformance(PerformanceData data) { if (!Faulted) _proxy.ReportPerformanceAsync(data); }