Skip to content

Commit a707e14

Browse files
authored
Merge pull request github#16338 from tamasvajk/buildless/extractor-timing
C#: Store buildless extraction timing information and return in telem…
2 parents e44d4c4 + 1d45e3a commit a707e14

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

csharp/extractor/Semmle.Extraction.CSharp.Standalone/Extractor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ private static void AnalyseStandalone(
4040
output.Name, syntaxTrees, references, new CSharpCompilationOptions(OutputKind.ConsoleApplication, allowUnsafe: true)
4141
),
4242
(compilation, options) => analyser.Initialize(output.FullName, extractionInput.CompilationInfos, compilation, options),
43-
_ => { },
4443
() =>
4544
{
4645
foreach (var type in analyser.MissingNamespaces)

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Analyser.cs

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ private void DoAnalyseCompilation()
245245
}
246246
}
247247

248+
public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);
249+
248250
#nullable restore warnings
249251

250252
/// <summary>

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
309309
Func<Analyser, List<SyntaxTree>, IEnumerable<Action>> getSyntaxTreeTasks,
310310
Func<IEnumerable<SyntaxTree>, IEnumerable<MetadataReference>, CSharpCompilation> getCompilation,
311311
Action<CSharpCompilation, CommonOptions> initializeAnalyser,
312-
Action<Entities.PerformanceMetrics> logPerformance,
313312
Action postProcess)
314313
{
315314
using var references = new BlockingCollection<MetadataReference>();
@@ -368,7 +367,7 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
368367
PeakWorkingSet = currentProcess.PeakWorkingSet64
369368
};
370369

371-
logPerformance(performance);
370+
analyser.LogPerformance(performance);
372371
analyser.Logger.Log(Severity.Info, " Extraction took {0}", sw.Elapsed);
373372

374373
postProcess();
@@ -422,7 +421,6 @@ private static ExitCode AnalyseTracing(
422421
);
423422
},
424423
(compilation, options) => analyser.EndInitialize(compilerArguments, options, compilation),
425-
performance => analyser.LogPerformance(performance),
426424
() => { });
427425
}
428426

csharp/extractor/Semmle.Extraction.CSharp/Extractor/TracingAnalyser.cs

-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ private IEnumerable<Diagnostic> FilteredDiagnostics
175175
Where(e => e.Severity >= DiagnosticSeverity.Error && !errorsToIgnore.Contains(e.Id));
176176
}
177177
}
178-
179-
public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);
180-
181178
#nullable restore warnings
182179
}
183180
}

csharp/ql/src/Telemetry/ExtractorInformation.ql

+10-1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ predicate analyzerAssemblies(string key, float value) {
201201
value = 1.0
202202
}
203203

204+
predicate timingValues(string key, float value) {
205+
exists(Compilation c |
206+
key = "Total elapsed seconds" and value = c.getElapsedSeconds()
207+
or
208+
key = "Extractor elapsed seconds" and value = c.getExtractorElapsedSeconds()
209+
)
210+
}
211+
204212
from string key, float value
205213
where
206214
(
@@ -230,7 +238,8 @@ where
230238
ExprStatsReport::numberOfOk(key, value) or
231239
ExprStatsReport::numberOfNotOk(key, value) or
232240
ExprStatsReport::percentageOfOk(key, value) or
233-
analyzerAssemblies(key, value)
241+
analyzerAssemblies(key, value) or
242+
timingValues(key, value)
234243
) and
235244
/* Infinity */
236245
value != 1.0 / 0.0 and

0 commit comments

Comments
 (0)