JS: additional extraction metrics cleanup

This commit is contained in:
Esben Sparre Andreasen
2019-09-05 09:07:23 +01:00
parent 03d38ca54b
commit 5d6997c1c9
5 changed files with 13 additions and 23 deletions

View File

@@ -1,8 +1,9 @@
/**
* @name File correlations
* @description
* @name Extraction metrics file data
* @description Extraction metrics and related information for profiling the extraction of individual files.
* @kind table
* @id js/meta/extraction/file-data
* @tags meta
*/
import javascript

View File

@@ -1,9 +1,11 @@
/**
* @name File with missing extraction metrics
* @description A file missing extraction metrics is indicative of a faulty extractor.
* @kind table
* @problem.severity error
* @kind problem
* @problem.severity warning
* @precision low
* @id js/meta/extraction/missing-metrics
* @tags meta
*/
import javascript

View File

@@ -3,12 +3,10 @@
* @description An overview of how time was spent during extraction
* @kind table
* @id js/meta/extraction/phase-timings
* @tags meta
*/
import semmle.javascript.meta.ExtractionMetrics::ExtractionMetrics
from PhaseName phaseName, float cpuTime, int cpuPerc
where
cpuTime = Aggregated::getCpuTime(phaseName) and
cpuPerc = ((cpuTime / Aggregated::getCpuTime()) * 100).floor()
select phaseName, cpuTime as CPU_NANO, cpuPerc as CPU_PERC
from PhaseName phaseName
select phaseName, Aggregated::getCpuTime(phaseName) as CPU_NANO, Aggregated::getWallclockTime(phaseName) as WALLCLOCK_NANO

View File

@@ -94,7 +94,6 @@ module ExtractionMetrics {
* The name of a phase of the extraction.
*/
class PhaseName extends string {
bindingset[this]
PhaseName() { this = getExtractionPhaseName(_) }
}
@@ -118,7 +117,6 @@ module ExtractionMetrics {
* Gets the total CPU time spent in phase `phaseName` of the extraction.
*/
float getCpuTime(PhaseName phaseName) {
/* bind */ phaseName = getExtractionPhaseName(_) and
result = strictsum(any(FileWithExtractionMetrics f).getCpuTime(phaseName))
}
@@ -126,16 +124,7 @@ module ExtractionMetrics {
* Gets the total wallclock time spent in phase `phaseName` of the extraction.
*/
float getWallclockTime(PhaseName phaseName) {
/* bind */ phaseName = getExtractionPhaseName(_) and
result = strictsum(any(FileWithExtractionMetrics f).getWallclockTime(phaseName))
}
}
/**
* Gets `nanoseconds` formatted as a whole number of milliseconds.
*/
bindingset[nanoSeconds]
string formatAsMilliSeconds(float nanoSeconds) {
result = (nanoSeconds / (1000 * 1000)).ceil() + ""
}
}

View File

@@ -1139,7 +1139,7 @@ configLocations(
/**
* The time taken for the extraction of a file.
* This table contains non-deternistic content.
* This table contains non-deterministic content.
*
* The sum of the `time` column for each (`file`, `timerKind`) pair
* is the total time taken for extraction of `file`. The `extractionPhase`
@@ -1149,14 +1149,14 @@ extraction_time(
int file : @file ref,
// see `com.semmle.js.extractor.ExtractionMetrics.ExtractionPhase`.
int extractionPhase: int ref,
// 0 for the elapsed CPU time in nanoseconds, 1 for the wall elapsed wallclock time in nanoseconds
// 0 for the elapsed CPU time in nanoseconds, 1 for the elapsed wallclock time in nanoseconds
int timerKind: int ref,
float time: float ref
)
/**
* Non-timing related data for the extraction of a single file.
* This table contains non-deternistic content.
* This table contains non-deterministic content.
*/
extraction_data(
int file : @file ref,