mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Kotlin: Record compilation and extraction times
This commit is contained in:
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
|||||||
|
|
||||||
class KotlinExtractorExtension(private val invocationTrapFile: String, private val checkTrapIdentical: Boolean) : IrGenerationExtension {
|
class KotlinExtractorExtension(private val invocationTrapFile: String, private val checkTrapIdentical: Boolean) : IrGenerationExtension {
|
||||||
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
|
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
|
||||||
|
val startTimeMs = System.currentTimeMillis()
|
||||||
// This default should be kept in sync with language-packs/java/tools/kotlin-extractor
|
// This default should be kept in sync with language-packs/java/tools/kotlin-extractor
|
||||||
val trapDir = File(System.getenv("CODEQL_EXTRACTOR_JAVA_TRAP_DIR").takeUnless { it.isNullOrEmpty() } ?: "kotlin-extractor/trap")
|
val trapDir = File(System.getenv("CODEQL_EXTRACTOR_JAVA_TRAP_DIR").takeUnless { it.isNullOrEmpty() } ?: "kotlin-extractor/trap")
|
||||||
FileOutputStream(File(invocationTrapFile), true).bufferedWriter().use { invocationTrapFileBW ->
|
FileOutputStream(File(invocationTrapFile), true).bufferedWriter().use { invocationTrapFileBW ->
|
||||||
@@ -52,7 +53,8 @@ class KotlinExtractorExtension(private val invocationTrapFile: String, private v
|
|||||||
// files etc, so we just exit when we are finished extracting.
|
// files etc, so we just exit when we are finished extracting.
|
||||||
logger.info("Extraction completed")
|
logger.info("Extraction completed")
|
||||||
logger.flush()
|
logger.flush()
|
||||||
tw.writeCompilation_finished(compilation, 0.0, 0.0)
|
val compilationTimeMs = System.currentTimeMillis() - startTimeMs
|
||||||
|
tw.writeCompilation_finished(compilation, -1.0, compilationTimeMs.toDouble() / 1000)
|
||||||
tw.flush()
|
tw.flush()
|
||||||
}
|
}
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
|
|||||||
@@ -116,6 +116,17 @@ diagnostic_for(
|
|||||||
int file_number_diagnostic_number : int ref
|
int file_number_diagnostic_number : int ref
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `cpu_seconds` and `elapsed_seconds` are the CPU time and elapsed
|
||||||
|
* time (respectively) that the original compilation (not the extraction)
|
||||||
|
* took for compiler invocation `id`.
|
||||||
|
*/
|
||||||
|
compilation_compiler_times(
|
||||||
|
unique int id : @compilation ref,
|
||||||
|
float cpu_seconds : float ref,
|
||||||
|
float elapsed_seconds : float ref
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If extraction was successful, then `cpu_seconds` and
|
* If extraction was successful, then `cpu_seconds` and
|
||||||
* `elapsed_seconds` are the CPU time and elapsed time (respectively)
|
* `elapsed_seconds` are the CPU time and elapsed time (respectively)
|
||||||
|
|||||||
@@ -70,6 +70,18 @@ class Compilation extends @compilation {
|
|||||||
*/
|
*/
|
||||||
string getArgument(int i) { compilation_args(this, i, result) }
|
string getArgument(int i) { compilation_args(this, i, result) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total amount of CPU time spent processing all the files in the
|
||||||
|
* compiler.
|
||||||
|
*/
|
||||||
|
float getCompilerCpuSeconds() { compilation_compiler_times(this, result, _) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total amount of elapsed time while processing all the files in
|
||||||
|
* the compiler.
|
||||||
|
*/
|
||||||
|
float getCompilerElapsedSeconds() { compilation_compiler_times(this, _, result) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total amount of CPU time spent processing all the files in the
|
* Gets the total amount of CPU time spent processing all the files in the
|
||||||
* front-end and extractor.
|
* front-end and extractor.
|
||||||
|
|||||||
Reference in New Issue
Block a user