mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C#: Fix elapsed timings and add a test for it.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user