private void WriteActualAndSimulationResults(PipExecutionData data, SimulationResult actualSimulation) { // write results actual File.WriteAllLines(GetResultsPath("actual.durations.csv"), data.Spans.Where(ps => data.GetPipType(ps.Id) == PipType.Process).Select(ps => string.Join(",", data.GetName(ps.Id), ps.Duration.ToMinutes().ToString()))); File.WriteAllLines(GetResultsPath("actual.durations.txt"), data.Spans.Select(ps => ps.Duration.ToMinutes().ToString())); File.WriteAllLines(GetResultsPath("actual.starts.txt"), data.Spans.Select(ps => ps.StartTime.ToMinutes().ToString())); File.WriteAllLines(GetResultsPath("actual.ends.txt"), data.Spans.Select(ps => ps.EndTime.ToMinutes().ToString())); // write simulation actual File.WriteAllLines(GetResultsPath("actualSimulation.durations.txt"), actualSimulation.GetSpans().Select(ps => ps.Duration.ToMinutes().ToString())); File.WriteAllLines(GetResultsPath("actualSimulation.starts.txt"), actualSimulation.GetSpans().Select(ps => ps.StartTime.ToMinutes().ToString())); File.WriteAllLines(GetResultsPath("actualSimulation.ends.txt"), actualSimulation.GetSpans().Select(ps => ps.EndTime.ToMinutes().ToString())); File.WriteAllLines(GetResultsPath("heights.txt"), data.Spans.Where(ps => data.GetPipType(ps.Id) == PipType.Process) .Select(ps => data.DirectedGraph.GetNodeHeight(ps.Id)) .GroupBy(i => i) .OrderBy(g => g.Key) .Select(g => $"Height: {g.Key}, Count: {g.Count()}")); // information on each process during simulation DisplayTable <SimColumns> table = new DisplayTable <SimColumns>(" , "); using (var streamWriter = new StreamWriter(GetResultsPath("actualSimulation.txt"))) { foreach (var ps in actualSimulation.GetSpans()) { table.NextRow(); table.Set(SimColumns.Id, data.FormattedSemistableHashes[ps.Id]); table.Set(SimColumns.Thread, ps.Thread); table.Set(SimColumns.MinimumStartTime, actualSimulation.MinimumStartTimes[ps.Id].ToMinutes()); table.Set(SimColumns.StartTime, ps.StartTime.ToMinutes()); table.Set(SimColumns.EndTime, ps.EndTime.ToMinutes()); table.Set(SimColumns.Duration, ps.Duration.ToMinutes()); table.Set(SimColumns.Incoming, data.DirectedGraph.GetIncomingEdgesCount(ps.Id)); table.Set(SimColumns.Outgoing, data.DirectedGraph.GetIncomingEdgesCount(ps.Id)); table.Set(SimColumns.LongestRunningDependency, data.FormattedSemistableHashes.GetOrDefault(actualSimulation.LongestRunningDependency[ps.Id])); table.Set(SimColumns.LastRunningDependency, data.FormattedSemistableHashes.GetOrDefault(actualSimulation.LastRunningDependency[ps.Id])); } table.Write(streamWriter); } }
private static void WriteActualAndSimulationResults(PipExecutionData data, SimulationResult actualSimulation) { // write results actual File.WriteAllLines(resultsFormat.FormatWith("actual.durations.csv"), data.Spans.Where(ps => data.GetPipType(ps.Id) == PipType.Process).Select(ps => string.Join(",", data.GetName(ps.Id), ps.Duration.ToMinutes().ToString()))); File.WriteAllLines(resultsFormat.FormatWith("actual.durations.txt"), data.Spans.Select(ps => ps.Duration.ToMinutes().ToString())); File.WriteAllLines(resultsFormat.FormatWith("actual.starts.txt"), data.Spans.Select(ps => ps.StartTime.ToMinutes().ToString())); File.WriteAllLines(resultsFormat.FormatWith("actual.ends.txt"), data.Spans.Select(ps => ps.EndTime.ToMinutes().ToString())); // write simulation actual File.WriteAllLines(resultsFormat.FormatWith("actualSimulation.durations.txt"), actualSimulation.GetSpans().Select(ps => ps.Duration.ToMinutes().ToString())); File.WriteAllLines(resultsFormat.FormatWith("actualSimulation.starts.txt"), actualSimulation.GetSpans().Select(ps => ps.StartTime.ToMinutes().ToString())); File.WriteAllLines(resultsFormat.FormatWith("actualSimulation.ends.txt"), actualSimulation.GetSpans().Select(ps => ps.EndTime.ToMinutes().ToString())); File.WriteAllLines(resultsFormat.FormatWith("heights.txt"), data.Spans.Where(ps => data.GetPipType(ps.Id) == PipType.Process) .Select(ps => data.DataflowGraph.GetNodeHeight(ps.Id)) .GroupBy(i => i) .OrderBy(g => g.Key) .Select(g => $"Height: {g.Key}, Count: {g.Count()}")); // information on each process during simulation string csvFormat = "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}"; File.WriteAllLines(resultsFormat.FormatWith("actualSimulation.txt"), new string[] { csvFormat.FormatWith("Id", "Thread", "Minimum Start Time", "Start Time", "End Time", "Duration", "Incoming", "Outgoing") }.Concat(actualSimulation.GetSpans().Select(ps => csvFormat.FormatWith( ps.Id.Value, ps.Thread, actualSimulation.MinimumStartTimes[ps.Id].ToMinutes(), ps.StartTime.ToMinutes(), ps.EndTime.ToMinutes(), ps.Duration.ToMinutes(), data.DataflowGraph.GetIncomingEdgesCount(ps.Id), data.DataflowGraph.GetIncomingEdgesCount(ps.Id))))); }