mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
[Kapt] Support dumping processors stats to a file
Using the option -Kapt-dump-processor-timings
This commit is contained in:
committed by
Andrey Zinovyev
parent
beba85a848
commit
b8002cb54f
@@ -320,7 +320,8 @@ private class KaptExecution @Inject constructor(
|
||||
detectMemoryLeaksMode,
|
||||
|
||||
processingClassLoader,
|
||||
disableClassloaderCacheForProcessors
|
||||
disableClassloaderCacheForProcessors,
|
||||
/*processorsPerfReportFile=*/null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ class KaptOptions(
|
||||
//if defined use it to run processors instead of creating new one
|
||||
val processingClassLoader: ClassLoader?,
|
||||
//construct new classloader for these processors instead of using one defined in processingClassLoader
|
||||
val separateClassloaderForProcessors: Set<String>
|
||||
val separateClassloaderForProcessors: Set<String>,
|
||||
val processorsPerfReportFile: File?
|
||||
) : KaptFlags {
|
||||
override fun get(flag: KaptFlag) = flags[flag]
|
||||
|
||||
@@ -72,6 +73,7 @@ class KaptOptions(
|
||||
|
||||
var mode: AptMode = AptMode.WITH_COMPILATION
|
||||
var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT
|
||||
var processorsPerfReportFile: File? = null
|
||||
|
||||
fun build(): KaptOptions {
|
||||
val sourcesOutputDir = this.sourcesOutputDir ?: error("'sourcesOutputDir' must be set")
|
||||
@@ -85,7 +87,8 @@ class KaptOptions(
|
||||
processingClasspath, processors, processingOptions, javacOptions, KaptFlags.fromSet(flags),
|
||||
mode, detectMemoryLeaks,
|
||||
processingClassLoader = null,
|
||||
separateClassloaderForProcessors = emptySet()
|
||||
separateClassloaderForProcessors = emptySet(),
|
||||
processorsPerfReportFile = processorsPerfReportFile
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ fun KaptContext.doAnnotationProcessing(
|
||||
showProcessorTimings(wrappedProcessors, loggerFun)
|
||||
}
|
||||
|
||||
options.processorsPerfReportFile?.let { dumpProcessorTiming(wrappedProcessors, options.processorsPerfReportFile, logger::info) }
|
||||
|
||||
if (logger.isVerbose) {
|
||||
filer.displayState()
|
||||
}
|
||||
@@ -142,6 +144,17 @@ private fun showProcessorTimings(wrappedProcessors: List<ProcessorWrapper>, logg
|
||||
}
|
||||
}
|
||||
|
||||
private fun dumpProcessorTiming(wrappedProcessors: List<ProcessorWrapper>, apReportFile: File, logger: (String) -> Unit) {
|
||||
logger("Dumping Kapt Annotation Processing performance report to ${apReportFile.absolutePath}")
|
||||
|
||||
apReportFile.writeText(buildString {
|
||||
appendLine("Kapt Annotation Processing performance report:")
|
||||
wrappedProcessors.forEach { processor ->
|
||||
appendLine(processor.renderSpentTime())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun reportIfRunningNonIncrementally(
|
||||
listener: MentionedTypesTaskListener?,
|
||||
cacheManager: JavaClassCacheManager?,
|
||||
|
||||
@@ -181,6 +181,13 @@ enum class KaptCliOption(
|
||||
cliToolOption = CliToolOption("-Kapt-show-processor-timings", FLAG)
|
||||
),
|
||||
|
||||
DUMP_PROCESSOR_TIMINGS(
|
||||
"dumpProcessorTimings",
|
||||
"<path>",
|
||||
"Dump processor performance statistics to the specified file",
|
||||
cliToolOption = CliToolOption("-Kapt-dump-processor-timings", VALUE)
|
||||
),
|
||||
|
||||
STRICT_MODE_OPTION(
|
||||
"strict",
|
||||
"true | false",
|
||||
|
||||
@@ -119,6 +119,7 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
|
||||
STRIP_METADATA_OPTION -> setFlag(KaptFlag.STRIP_METADATA, value)
|
||||
KEEP_KDOC_COMMENTS_IN_STUBS -> setFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, value)
|
||||
SHOW_PROCESSOR_TIMINGS -> setFlag(KaptFlag.SHOW_PROCESSOR_TIMINGS, value)
|
||||
DUMP_PROCESSOR_TIMINGS -> processorsPerfReportFile = File(value)
|
||||
INCLUDE_COMPILE_CLASSPATH -> setFlag(KaptFlag.INCLUDE_COMPILE_CLASSPATH, value)
|
||||
|
||||
DETECT_MEMORY_LEAKS_OPTION -> setSelector(enumValues<DetectMemoryLeaksMode>(), value) { detectMemoryLeaks = it }
|
||||
|
||||
Reference in New Issue
Block a user