Exemple #1
0
 public async static Task ReadBinlog(AggregateData aggregate, string filePath)
 {
     ProcessStartInfo psi = new()
     {
         FileName               = "dotnet",
         ArgumentList           = { "msbuild", "-consoleLoggerParameters:verbosity=quiet;PerformanceSummary", filePath },
         RedirectStandardOutput = true,
     };
Exemple #2
0
        static void ReadETWFile(AggregateData aggregate, string fileName)
        {
            ZippedETLReader zipReader = new ZippedETLReader(fileName, Console.Out);

            zipReader.UnpackArchive();

            var traceLog = TraceLog.OpenOrConvert(fileName.Substring(0, fileName.Length - 4), new TraceLogOptions()
            {
                ConversionLog = Console.Out
            });
            var evts = traceLog.Events.Filter(e => e.ProviderName.Equals("Microsoft-Build"));
            Dictionary <string, Dictionary <int, double> > startTimes = new Dictionary <string, Dictionary <int, double> >();
            List <Tuple <string, string, double> >         events     = new();

            foreach (var evt in evts.Where(e => e.EventName.Contains("ExecuteTask") || e.EventName.Contains("Target")))
            {
                string key = evt.EventName.Contains("Target") ? "Target," + evt.PayloadValue(evt.PayloadIndex("targetName")) : "Task," + evt.PayloadValue(evt.PayloadIndex("taskName"));
                if (evt.EventName.Contains("Start"))
                {
                    if (startTimes.TryGetValue(key, out Dictionary <int, double>?latest))
                    {
                        latest[evt.ThreadID] = evt.TimeStampRelativeMSec;
                    }
                    else
                    {
                        startTimes.Add(key, new Dictionary <int, double>()
                        {
                            { evt.ThreadID, evt.TimeStampRelativeMSec }
                        });
                    }
                }
                else
                {
                    try
                    {
                        double startTime = startTimes[key][evt.ThreadID];
                        events.Add(Tuple.Create(key.Split(',')[0], key.Split(',')[1], evt.TimeStampRelativeMSec - startTime));
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            events = events.GroupBy(t => t.Item2, (key, enumerable) => enumerable.Aggregate((f, s) => Tuple.Create(f.Item1, f.Item2, f.Item3 + s.Item3))).ToList();
            events.Sort((f, s) => f.Item3 > s.Item3 ? -1 : f.Item3 == s.Item3 ? 0 : 1);
            List <TaskSummary> tasks = new();

            foreach (var evt in events)
            {
                tasks.Add(new(evt.Item2, evt.Item3));
            }

            aggregate.AddBuild(fileName.Substring(0, fileName.Length - 8), tasks);
        }
Exemple #3
0
        async static Task Run(FileInfo[] inputs, FileInfo output, bool show)
        {
            AggregateData aggregate = await Aggregate(inputs);

            await aggregate.WriteCsv(output.FullName);

            if (show)
            {
                aggregate.ShowChart();
            }
        }
Exemple #4
0
        public async static Task ReadFile(AggregateData aggregate, string filePath)
        {
            using var file = new StreamReader(filePath);

            await ReadFile(aggregate, file, filePath);
        }