/// <summary> /// Returns summary by statuses for the given experiment. /// If summary for the given parameters has not been computed yet, /// builds the summary and saves it. /// </summary> /// <param name="expId">Target experiment.</param> /// <param name="refExpId">Optional; another experiment to compare performance with.</param> public async Task <ExperimentStatusSummary> GetStatusSummary(int expId, int?refExpId) { Trace.WriteLine("Check if the summary already exists..."); ExperimentStatusSummary summary = await TryDownloadStatusSummary(expId, refExpId); if (summary != null) { Trace.WriteLine("Ok, summary found."); return(summary); } Trace.WriteLine("Downloading experiment information..."); var exp = await storage.GetExperiment(expId); // fails if not found var domain = resolveDomain.GetDomain(exp.DomainName); Trace.WriteLine("Downloading experiment results..."); BenchmarkResult[] results = (await storage.GetResults(expId)).Benchmarks; BenchmarkResult[] refResults = null; if (refExpId.HasValue) { Trace.WriteLine("Downloading another experiment results..."); refResults = (await storage.GetResults(refExpId.Value)).Benchmarks; } Trace.WriteLine("Building summary..."); summary = ExperimentStatusSummary.Build(expId, results, refExpId, refResults, domain); Trace.WriteLine("Uploading summary..."); await UploadStatusSummary(summary); return(summary); }
private static AlertSet FindCategoryAlerts(ExperimentSummary summary, ExperimentStatusSummary statusSummary, string category) { AlertSet res = new AlertSet(); // Check for bugs != 0; This is critical. int bugs = category == "" ? summary.Overall.Bugs : summary.CategorySummary[category].Bugs; if (bugs != 0) { res.Add(AlertLevel.Critical, string.Format("There {0} {1} bug{2}.", bugs == 1 ? "is" : "are", bugs, bugs == 1 ? "" : "s")); } // Infrastructure errors; this is just an information. int ierrs = category == "" ? summary.Overall.InfrastructureErrors : summary.CategorySummary[category].InfrastructureErrors; if (ierrs != 0) { res.Add(AlertLevel.None, string.Format("There {0} {1} infrastructure error{2}.", ierrs == 1 ? "is" : "are", ierrs, ierrs == 1 ? "" : "s")); } // Check for errors != 0; this is just a warning. int errors = category == "" ? summary.Overall.Errors : summary.CategorySummary[category].Errors; if (errors != 0) { res.Add(AlertLevel.Warning, string.Format("There {0} {1} error{2}.", errors == 1 ? "is" : "are", errors, errors == 1 ? "" : "s")); } // See whether something got slower. int dippers = GetStatuses(statusSummary.DippersByCategory, category).Count; if (dippers != 0) { res.Add(AlertLevel.None, string.Format("There {0} {1} benchmark{2} that show{3} a dip in performance.", dippers == 1 ? "is" : "are", dippers, dippers == 1 ? "" : "s", dippers == 1 ? "s" : "")); } return(res); }
private async Task UploadStatusSummary(ExperimentStatusSummary summary) { string fileName = GetStatusSummaryFileName(summary.Id, summary.ReferenceId); string blobName = GetStatusSummaryBlobName(fileName); var blob = summaryContainer.GetBlockBlobReference(blobName); using (Stream zipStream = new MemoryStream()) { using (ZipFile zip = new ZipFile()) using (MemoryStream mem = new MemoryStream()) { ExperimentStatusSummaryStorage.Save(summary, mem); mem.Position = 0; zip.AddEntry(fileName, mem); zip.Save(zipStream); } zipStream.Position = 0; await blob.UploadFromStreamAsync(zipStream, AccessCondition.GenerateEmptyCondition(), new BlobRequestOptions { RetryPolicy = retryPolicy }, null); } }
public ExperimentAlerts(ExperimentSummary summary, ExperimentStatusSummary statusSummary, string _linkPage) { alertSets = new Dictionary <string, AlertSet>(); var overall = new AlertSet(); foreach (var catSum in summary.CategorySummary) { if (catSum.Key != "") { var set = FindCategoryAlerts(summary, statusSummary, catSum.Key); alertSets.Add(catSum.Key, set); if (set.Messages.Count != 0) { overall.Add(set.Level, string.Format("{0} alert{1} in <a href='" + _linkPage + "?cat={2}' style='text-decoration:none;'>{2}</a>.", set.Count, set.Count == 1 ? "" : "s", catSum.Key)); } } } alertSets.Add("", overall); }