C#: Store buildless extraction timing information and return in telemetry query

This commit is contained in:
Tamas Vajk
2024-04-26 14:59:31 +02:00
parent e44d4c45aa
commit 1d45e3a558
5 changed files with 13 additions and 8 deletions

View File

@@ -40,7 +40,6 @@ namespace Semmle.Extraction.CSharp.Standalone
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)

View File

@@ -245,6 +245,8 @@ namespace Semmle.Extraction.CSharp
}
}
public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);
#nullable restore warnings
/// <summary>

View File

@@ -309,7 +309,6 @@ namespace Semmle.Extraction.CSharp
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>();
@@ -368,7 +367,7 @@ namespace Semmle.Extraction.CSharp
PeakWorkingSet = currentProcess.PeakWorkingSet64
};
logPerformance(performance);
analyser.LogPerformance(performance);
analyser.Logger.Log(Severity.Info, " Extraction took {0}", sw.Elapsed);
postProcess();
@@ -422,7 +421,6 @@ namespace Semmle.Extraction.CSharp
);
},
(compilation, options) => analyser.EndInitialize(compilerArguments, options, compilation),
performance => analyser.LogPerformance(performance),
() => { });
}

View File

@@ -175,9 +175,6 @@ namespace Semmle.Extraction.CSharp
Where(e => e.Severity >= DiagnosticSeverity.Error && !errorsToIgnore.Contains(e.Id));
}
}
public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);
#nullable restore warnings
}
}

View File

@@ -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
(
@@ -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