static async Task<bool> UploadPauseTimes (string binprotFilePath, string grepBinprotPath, long runId) { var grepString = Utils.RunForStdout (grepBinprotPath, null, "--pause-times", "--input", binprotFilePath); if (grepString == null) { Console.Error.WriteLine ("Error: sgen-grep-binprot failed."); return false; } var times = new List<double> (); var starts = new List<double> (); foreach (var line in grepString.Split ('\n')) { var fields = line.Split (' ', '\t'); if (fields.Count () < 6) continue; if (fields [0] != "pause-time") continue; var ticks = Int64.Parse (fields [4]); var ms = (double)ticks / 10000.0; times.Add (ms); ticks = Int64.Parse (fields [5]); ms = (double)ticks / 10000.0; starts.Add (ms); } if (times.Count == 0) { Console.Error.WriteLine ("Error: no pause times."); return false; } Console.WriteLine ("Uploading pause times: {0}", string.Join (" ", times)); var run = new Run (); run.RunMetrics.Add (new RunMetric { Metric = RunMetric.MetricType.PauseTimes, Value = times.ToArray () }); run.RunMetrics.Add (new RunMetric { Metric = RunMetric.MetricType.PauseStarts, Value = starts.ToArray () }); return await run.UploadForAmend (runId); }
static async Task<bool> UploadPauseTimes (string binprotFilePath, string grepBinprotPath, long runId) { var grepString = Utils.RunForStdout (grepBinprotPath, null, "--pause-times", "--input", binprotFilePath); if (grepString == null) { Console.Error.WriteLine ("Error: sgen-grep-binprot failed."); return false; } var times = new List<double> (); var starts = new List<double> (); foreach (var line in grepString.Split ('\n')) { var fields = line.Split (' ', '\t'); if (fields.Count () < 6) continue; if (fields [0] != "pause-time") continue; var ticks = Int64.Parse (fields [4]); var ms = (double)ticks / 10000.0; times.Add (ms); ticks = Int64.Parse (fields [5]); ms = (double)ticks / 10000.0; starts.Add (ms); } if (times.Count == 0) { Console.Error.WriteLine ("Error: no pause times."); return false; } var run = new Run (); run.RunMetrics.Add (new RunMetric { Metric = RunMetric.MetricType.PauseTimes, Value = times.ToArray () }); run.RunMetrics.Add (new RunMetric { Metric = RunMetric.MetricType.PauseStarts, Value = starts.ToArray () }); Console.WriteLine (JsonConvert.SerializeObject (run.AsDict ())); for (int i = 0; i < 5; i++) { if (await run.UploadForAmend (runId)) return true; Console.Error.WriteLine ("retry run upload: #{0} at {1}" ,i ,DateTime.Now.ToString (RunSet.DATETIME_PRETTY)); System.Threading.Thread.Sleep (i * 10000); } return false; }