C#: Fix elapsed timings and add a test for it.

This commit is contained in:
calum
2019-04-16 16:14:57 +01:00
committed by Calum Grant
parent c67e441003
commit 39bb3f2d52
5 changed files with 23 additions and 9 deletions

View File

@@ -63,6 +63,7 @@ namespace Semmle.Extraction.CSharp
public static ExitCode Run(string[] args)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var commandLineArguments = Options.CreateWithEnvironment(args);
var fileLogger = new FileLogger(commandLineArguments.Verbosity, GetCSharpLogPath());
var logger = commandLineArguments.Console

View File

@@ -56,4 +56,10 @@ class Compilation extends @compilation {
/** Gets the peak working set of the extractor process in MB. */
float getPeakWorkingSetMB() { result = getMetric(6) }
/** Gets the CPU seconds for the entire extractor process. */
float getCpuSeconds() { compilation_finished(this, result, _) }
/** Gets the elapsed seconds for the entire extractor process. */
float getElapsedSeconds() { compilation_finished(this, _, result) }
}

View File

@@ -77,7 +77,7 @@ class ExtractorMessage extends @extractor_message {
/** Gets the name of the extractor that produced this message, for example, `C# extractor`. */
string getOrigin() { result = origin }
/** Gets the text of this diagnostic. */
/** Gets the text of this message. */
string getText() { result = text }
/** Gets the textual representation of the entity that triggered this message. */

View File

@@ -29,9 +29,11 @@ diagnosticElements
| Program.cs:9:13:9:13 | CS0219: The variable 'y' is assigned but its value is never used | Program.cs:9:13:9:13 | access to local variable y |
| Program.cs:9:13:9:13 | CS0219: The variable 'y' is assigned but its value is never used | Program.cs:9:13:9:13 | y |
references
| compilation | 0 | System.Core.dll |
| compilation | 1 | System.Console.dll |
| compilation | 2 | mscorlib.dll |
| compilation | 3 | System.Runtime.dll |
| compilation | 4 | System.dll |
| compilation | 5 | System.Private.CoreLib.dll |
| compilation | System.Console.dll |
| compilation | System.Core.dll |
| compilation | System.Private.CoreLib.dll |
| compilation | System.Runtime.dll |
| compilation | System.dll |
| compilation | mscorlib.dll |
timings
| compilation |

View File

@@ -31,6 +31,11 @@ query predicate compilationFolder(Compilation c, string folder) {
query predicate diagnosticElements(Diagnostic d, Element e) { e = d.getElement() }
query predicate references(Compilation c, int i, string reference) {
reference = c.getReference(i).getBaseName()
query predicate references(Compilation c, string reference) {
reference = c.getAReference().getBaseName()
}
query predicate timings(Compilation c) {
c.getCpuSeconds() > 0 and
c.getElapsedSeconds() > 0
}