static async Task <IEnumerable <string> > WarnIfNecessary(bool testRun, List <string> benchmarksToWarn, List <string> warnedBenchmarks, bool faster, PostgresRow testRunSet, PostgresRow previousRunSet, string machineName, string configName) { var newlyWarned = benchmarksToWarn.Where(b => !warnedBenchmarks.Contains(b)).ToList(); if (newlyWarned.Count == 0) { return new string[] { } } ; var commit = testRunSet.GetReference <string> ("c_hash"); var previousCommit = previousRunSet.GetReference <string> ("c_hash"); string benchmarksString; if (newlyWarned.Count == 1) { benchmarksString = String.Format("benchmark `{0}`", newlyWarned [0]); } else if (newlyWarned.Count == 2) { benchmarksString = String.Format("benchmarks `{0}` and `{1}`", newlyWarned [0], newlyWarned [1]); } else { var allButLast = newlyWarned.GetRange(0, newlyWarned.Count - 1).Select(n => String.Format("`{0}`", n)); benchmarksString = String.Format("benchmarks {0}, and `{1}`", String.Join(", ", allButLast), newlyWarned.Last()); } var timelineUrl = String.Format("http://xamarin.github.io/benchmarker/front-end/index.html#machine={0}&config={1}", machineName, configName); var compareUrl = String.Format("http://xamarin.github.io/benchmarker/front-end/compare.html#ids={0}+{1}", previousRunSet.GetValue <long> ("rs_id").Value, testRunSet.GetValue <long> ("rs_id").Value); var message = String.Format("The {0} got {1} between commits {2} and {3} on <{4}|{5}> — <{6}|compare>", benchmarksString, (faster ? "faster" : "slower"), SlackCommitString(previousCommit), SlackCommitString(commit), timelineUrl, testRunSet.GetReference <string> ("m_architecture"), compareUrl); var botName = faster ? "goodbot" : "badbot"; if (testRun) { Console.WriteLine("{0}: {1}", botName, message); } else { await SendSlackMessage(message, "#performance-bots", botName, faster? ":thumbsup:" : ":red_circle:"); } return(newlyWarned); }
static async Task<IEnumerable<string>> WarnIfNecessary (bool testRun, List<string> benchmarksToWarn, List<string> warnedBenchmarks, bool faster, PostgresRow testRunSet, PostgresRow previousRunSet, string machineName, string configName) { var newlyWarned = benchmarksToWarn.Where (b => !warnedBenchmarks.Contains (b)).ToList (); if (newlyWarned.Count == 0) return new string[] { }; var commit = testRunSet.GetReference<string> ("c_hash"); var previousCommit = previousRunSet.GetReference<string> ("c_hash"); string benchmarksString; if (newlyWarned.Count == 1) { benchmarksString = String.Format ("benchmark `{0}`", newlyWarned [0]); } else if (newlyWarned.Count == 2) { benchmarksString = String.Format ("benchmarks `{0}` and `{1}`", newlyWarned [0], newlyWarned [1]); } else { var allButLast = newlyWarned.GetRange (0, newlyWarned.Count - 1).Select (n => String.Format ("`{0}`", n)); benchmarksString = String.Format ("benchmarks {0}, and `{1}`", String.Join (", ", allButLast), newlyWarned.Last ()); } var timelineUrl = String.Format ("http://xamarin.github.io/benchmarker/front-end/index.html#machine={0}&config={1}", machineName, configName); var compareUrl = String.Format ("http://xamarin.github.io/benchmarker/front-end/compare.html#ids={0}+{1}", previousRunSet.GetValue<long> ("rs_id").Value, testRunSet.GetValue<long> ("rs_id").Value); var message = String.Format ("The {0} got {1} between commits {2} and {3} on <{4}|{5}> — <{6}|compare>", benchmarksString, (faster ? "faster" : "slower"), SlackCommitString (previousCommit), SlackCommitString (commit), timelineUrl, testRunSet.GetReference<string> ("m_architecture"), compareUrl); var botName = faster ? "goodbot" : "badbot"; if (testRun) Console.WriteLine ("{0}: {1}", botName, message); else await SendSlackMessage (message, "#performance-bots", botName, faster ? ":thumbsup:" : ":red_circle:"); return newlyWarned; }