Skip to content

Commit

Permalink
C#: Store buildless extraction timing information and return in telem…
Browse files Browse the repository at this point in the history
…etry query
  • Loading branch information
tamasvajk committed Apr 26, 2024
1 parent e44d4c4 commit 1d45e3a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ private static void AnalyseStandalone(
output.Name, syntaxTrees, references, new CSharpCompilationOptions(OutputKind.ConsoleApplication, allowUnsafe: true)
),
(compilation, options) => analyser.Initialize(output.FullName, extractionInput.CompilationInfos, compilation, options),
_ => { },
() =>
{
foreach (var type in analyser.MissingNamespaces)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ private void DoAnalyseCompilation()
}
}

public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);

#nullable restore warnings

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
Func<Analyser, List<SyntaxTree>, IEnumerable<Action>> getSyntaxTreeTasks,
Func<IEnumerable<SyntaxTree>, IEnumerable<MetadataReference>, CSharpCompilation> getCompilation,
Action<CSharpCompilation, CommonOptions> initializeAnalyser,
Action<Entities.PerformanceMetrics> logPerformance,
Action postProcess)
{
using var references = new BlockingCollection<MetadataReference>();
Expand Down Expand Up @@ -368,7 +367,7 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
PeakWorkingSet = currentProcess.PeakWorkingSet64
};

logPerformance(performance);
analyser.LogPerformance(performance);
analyser.Logger.Log(Severity.Info, " Extraction took {0}", sw.Elapsed);

postProcess();
Expand Down Expand Up @@ -422,7 +421,6 @@ private static ExitCode AnalyseTracing(
);
},
(compilation, options) => analyser.EndInitialize(compilerArguments, options, compilation),
performance => analyser.LogPerformance(performance),
() => { });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ private IEnumerable<Diagnostic> FilteredDiagnostics
Where(e => e.Severity >= DiagnosticSeverity.Error && !errorsToIgnore.Contains(e.Id));
}
}

public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);

#nullable restore warnings
}
}
11 changes: 10 additions & 1 deletion csharp/ql/src/Telemetry/ExtractorInformation.ql
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ predicate analyzerAssemblies(string key, float value) {
value = 1.0
}

predicate timingValues(string key, float value) {
exists(Compilation c |
key = "Total elapsed seconds" and value = c.getElapsedSeconds()
or
key = "Extractor elapsed seconds" and value = c.getExtractorElapsedSeconds()
)
}

from string key, float value
where
(
Expand Down Expand Up @@ -230,7 +238,8 @@ where
ExprStatsReport::numberOfOk(key, value) or
ExprStatsReport::numberOfNotOk(key, value) or
ExprStatsReport::percentageOfOk(key, value) or
analyzerAssemblies(key, value)
analyzerAssemblies(key, value) or
timingValues(key, value)
) and
/* Infinity */
value != 1.0 / 0.0 and
Expand Down

0 comments on commit 1d45e3a

Please sign in to comment.