Exemple #1
0
        private static ulong WriteCriticalPathToResult(MultiWriter writers, PipExecutionData data, SimulationResult testSimulation)
        {
            int   nameWidth;
            int   count            = 0;
            ulong criticalPathCost = 0;

            foreach (var p in data.GetSortedPips(2, true, n => data.GetPipType(n) == PipType.Process, n => data.AggregateCosts[n]))
            {
                // this is the actual critical path. This is not associated with the simulation as it only correlates to the dgg
                List <NodeId> criticalPath      = new List <NodeId>();
                NodeId        criticalChainNode = p.Node;
                while (criticalChainNode.IsValid)
                {
                    criticalPath.Add(criticalChainNode);
                    criticalChainNode = data.CriticalChain[criticalChainNode];
                }

                p.Priority.Max(ref criticalPathCost);

                writers.WriteLine("Critical Path {0}:", count++);
                writers.WriteLine("Critical Path Cost: {0} min", p.Priority.ToMinutes());
                writers.WriteLine("Critical Path Length: {0}", criticalPath.Count);
                nameWidth = criticalPath.Select(n => data.GetName(n).Length).Max();
                writers.WriteLine("Critical Path:\n    {0}", string.Join(Environment.NewLine + " -> ", criticalPath

                                                                         // .Where(n => data.Durations[n] > 0)
                                                                         .Select(n => string.Format(
                                                                                     "{0} ({1} min) [{2}] <{3}> [{4},{5}]",

                                                                                     // .Select(n => string.Format("{0} ({1} min) [{2}] <{3}>",
                                                                                     data.GetName(n).PadLeft(nameWidth),
                                                                                     data.Durations[n].ToMinutes(),
                                                                                     data.PipIds[n],
                                                                                     data.GetPipType(n),
                                                                                     testSimulation.StartTimes[n].ToMinutes(),
                                                                                     testSimulation.EndTimes[n].ToMinutes()))));

                // data.PipTypes[n]))));
            }

            return(criticalPathCost);
        }
Exemple #2
0
        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)))));
        }
Exemple #3
0
        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);
            }
        }