From ffb51d8a2360de9ec00547956efd41491dab11b0 Mon Sep 17 00:00:00 2001 From: Serge Mera Date: Tue, 5 Dec 2017 15:13:56 -0800 Subject: [PATCH] An empty profiler report, which just a header, is possible --- .../Profiler/ProfilerResultPrettyPrinter.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Build/Evaluation/Profiler/ProfilerResultPrettyPrinter.cs b/src/Build/Evaluation/Profiler/ProfilerResultPrettyPrinter.cs index 383cdbb51a4..b64865138f9 100644 --- a/src/Build/Evaluation/Profiler/ProfilerResultPrettyPrinter.cs +++ b/src/Build/Evaluation/Profiler/ProfilerResultPrettyPrinter.cs @@ -27,18 +27,25 @@ public sealed class ProfilerResultPrettyPrinter /// public static string GetMarkdownContent(ProfilerResult result) { + var stringBuilder = new StringBuilder(); + + stringBuilder.AppendLine("Pass|File|Line #|Expression|Inc (ms)|Inc (%)|Exc (ms)|Exc (%)|#|Bug"); + stringBuilder.AppendLine("---|---|---:|---|---:|---:|---:|---:|---:|---"); + var profiledLocations = result.ProfiledLocations; + + // If there are no profiled locations, then just return + if (profiledLocations.Count == 0) + { + return stringBuilder.ToString(); + } + var evaluationPasses = profiledLocations.Where(l => l.Key.File == null) .OrderBy(l => l.Key.EvaluationPass); var orderedLocations = profiledLocations.Where(l => l.Key.File != null) .OrderByDescending(l => l.Value.ExclusiveTime); - var stringBuilder = new StringBuilder(); - - stringBuilder.AppendLine("Pass|File|Line #|Expression|Inc (ms)|Inc (%)|Exc (ms)|Exc (%)|#|Bug"); - stringBuilder.AppendLine("---|---|---:|---|---:|---:|---:|---:|---:|---"); - TimeSpan? totalTime = null; foreach (var pair in evaluationPasses) {