C#: Store compilations, compiler diagnostics and performance in the database.

This commit is contained in:
calum
2019-03-21 17:57:27 +00:00
committed by Calum Grant
parent 4cc23cce13
commit e1158bb5e5
17 changed files with 484 additions and 15 deletions

View File

@@ -118,8 +118,8 @@ namespace Semmle.Extraction.CSharp
compilerArguments.Encoding,
syntaxTrees);
var sw = new Stopwatch();
sw.Start();
var sw1 = new Stopwatch();
sw1.Start();
Parallel.Invoke(
new ParallelOptions { MaxDegreeOfParallelism = commandLineArguments.Threads },
@@ -148,6 +148,7 @@ namespace Semmle.Extraction.CSharp
);
analyser.Initialize(compilerArguments, compilation, commandLineArguments, compilerVersion.ArgsWithResponse);
analyser.AnalyseCompilation(cwd, args);
analyser.AnalyseReferences();
foreach (var tree in compilation.SyntaxTrees)
@@ -155,13 +156,28 @@ namespace Semmle.Extraction.CSharp
analyser.AnalyseTree(tree);
}
sw.Stop();
logger.Log(Severity.Info, " Models constructed in {0}", sw.Elapsed);
var currentProcess = Process.GetCurrentProcess();
var cpuTime1 = currentProcess.TotalProcessorTime;
var userTime1 = currentProcess.UserProcessorTime;
sw1.Stop();
logger.Log(Severity.Info, " Models constructed in {0}", sw1.Elapsed);
sw.Restart();
var sw2 = new Stopwatch();
sw2.Start();
analyser.PerformExtraction(commandLineArguments.Threads);
sw.Stop();
logger.Log(Severity.Info, " Extraction took {0}", sw.Elapsed);
sw2.Stop();
var cpuTime2 = currentProcess.TotalProcessorTime;
var userTime2 = currentProcess.UserProcessorTime;
var performance = new Entities.Performance()
{
Compiler = new Entities.Timings() { Elapsed = sw1.Elapsed, Cpu = cpuTime1, User = userTime1 },
Extractor = new Entities.Timings() { Elapsed = sw2.Elapsed, Cpu = cpuTime2 - cpuTime1, User = userTime2 - userTime1 },
PeakWorkingSet = currentProcess.PeakWorkingSet64
};
analyser.LogPerformance(performance);
logger.Log(Severity.Info, " Extraction took {0}", sw2.Elapsed);
return analyser.TotalErrors == 0 ? ExitCode.Ok : ExitCode.Errors;
}