Rename params show/dumpProcessorTimings to show/dumpProcessorStats

^KT-51132 Fixed
This commit is contained in:
Udi Cohen
2022-02-02 15:07:02 -05:00
committed by teamcity
parent eb3b9f148d
commit c9d2f40b95
7 changed files with 31 additions and 27 deletions
@@ -46,9 +46,9 @@ interface KaptExtensionConfig {
var stripMetadata: Boolean var stripMetadata: Boolean
/** /**
* If `true`, show annotation processor timings. * If `true`, show annotation processor stats.
*/ */
var showProcessorTimings: Boolean var showProcessorStats: Boolean
/** /**
* If `true`, detect memory leaks in annotation processors. * If `true`, detect memory leaks in annotation processors.
@@ -491,7 +491,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
) )
pluginOptions += SubpluginOption("stripMetadata", "${kaptExtension.stripMetadata}") pluginOptions += SubpluginOption("stripMetadata", "${kaptExtension.stripMetadata}")
pluginOptions += SubpluginOption("keepKdocCommentsInStubs", "${project.isKaptKeepKdocCommentsInStubs()}") pluginOptions += SubpluginOption("keepKdocCommentsInStubs", "${project.isKaptKeepKdocCommentsInStubs()}")
pluginOptions += SubpluginOption("showProcessorTimings", "${kaptExtension.showProcessorTimings}") pluginOptions += SubpluginOption("showProcessorStats", "${kaptExtension.showProcessorStats}")
pluginOptions += SubpluginOption("detectMemoryLeaks", kaptExtension.detectMemoryLeaks) pluginOptions += SubpluginOption("detectMemoryLeaks", kaptExtension.detectMemoryLeaks)
pluginOptions += SubpluginOption("infoAsWarnings", "${project.isInfoAsWarnings()}") pluginOptions += SubpluginOption("infoAsWarnings", "${project.isInfoAsWarnings()}")
pluginOptions += FilesSubpluginOption("stubs", listOf(getKaptStubsDir())) pluginOptions += FilesSubpluginOption("stubs", listOf(getKaptStubsDir()))
@@ -40,7 +40,7 @@ open class KaptExtension: KaptExtensionConfig {
override var stripMetadata: Boolean = false override var stripMetadata: Boolean = false
override var showProcessorTimings: Boolean = false override var showProcessorStats: Boolean = false
override var detectMemoryLeaks: String = "default" override var detectMemoryLeaks: String = "default"
@@ -43,7 +43,7 @@ class KaptOptions(
val processingClassLoader: ClassLoader?, val processingClassLoader: ClassLoader?,
//construct new classloader for these processors instead of using one defined in processingClassLoader //construct new classloader for these processors instead of using one defined in processingClassLoader
val separateClassloaderForProcessors: Set<String>, val separateClassloaderForProcessors: Set<String>,
val processorsPerfReportFile: File? val processorsStatsReportFile: File?
) : KaptFlags { ) : KaptFlags {
override fun get(flag: KaptFlag) = flags[flag] override fun get(flag: KaptFlag) = flags[flag]
@@ -73,7 +73,7 @@ class KaptOptions(
var mode: AptMode = AptMode.WITH_COMPILATION var mode: AptMode = AptMode.WITH_COMPILATION
var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT
var processorsPerfReportFile: File? = null var processorsStatsReportFile: File? = null
fun build(): KaptOptions { fun build(): KaptOptions {
val sourcesOutputDir = this.sourcesOutputDir ?: error("'sourcesOutputDir' must be set") val sourcesOutputDir = this.sourcesOutputDir ?: error("'sourcesOutputDir' must be set")
@@ -88,7 +88,7 @@ class KaptOptions(
mode, detectMemoryLeaks, mode, detectMemoryLeaks,
processingClassLoader = null, processingClassLoader = null,
separateClassloaderForProcessors = emptySet(), separateClassloaderForProcessors = emptySet(),
processorsPerfReportFile = processorsPerfReportFile processorsStatsReportFile = processorsStatsReportFile
) )
} }
} }
@@ -114,7 +114,7 @@ interface KaptFlags {
} }
enum class KaptFlag(val description: String, val defaultValue: Boolean = false) { enum class KaptFlag(val description: String, val defaultValue: Boolean = false) {
SHOW_PROCESSOR_TIMINGS("Show processor time"), SHOW_PROCESSOR_STATS("Show processor stats"),
VERBOSE("Verbose mode"), VERBOSE("Verbose mode"),
INFO_AS_WARNINGS("Info as warnings"), INFO_AS_WARNINGS("Info as warnings"),
USE_LIGHT_ANALYSIS("Use light analysis", defaultValue = true), USE_LIGHT_ANALYSIS("Use light analysis", defaultValue = true),
@@ -116,13 +116,13 @@ fun KaptContext.doAnnotationProcessing(
logger.info("Annotation processing complete, errors: $errorCount, warnings: $warningCount") logger.info("Annotation processing complete, errors: $errorCount, warnings: $warningCount")
} }
val showProcessorTimings = options[KaptFlag.SHOW_PROCESSOR_TIMINGS] val showProcessorStats = options[KaptFlag.SHOW_PROCESSOR_STATS]
if (logger.isVerbose || showProcessorTimings) { if (logger.isVerbose || showProcessorStats) {
val loggerFun = if (showProcessorTimings) logger::warn else logger::info val loggerFun = if (showProcessorStats) logger::warn else logger::info
showProcessorTimings(wrappedProcessors, loggerFun) showProcessorStats(wrappedProcessors, loggerFun)
} }
options.processorsPerfReportFile?.let { dumpProcessorTiming(wrappedProcessors, options.processorsPerfReportFile, logger::info) } options.processorsStatsReportFile?.let { dumpProcessorStats(wrappedProcessors, it, logger::info) }
if (logger.isVerbose) { if (logger.isVerbose) {
filer.displayState() filer.displayState()
@@ -137,14 +137,18 @@ fun KaptContext.doAnnotationProcessing(
} }
} }
private fun showProcessorTimings(wrappedProcessors: List<ProcessorWrapper>, logger: (String) -> Unit) { private fun showProcessorStats(wrappedProcessors: List<ProcessorWrapper>, logger: (String) -> Unit) {
logger("Annotation processor stats:") logger("Annotation processor stats:")
wrappedProcessors.forEach { processor -> wrappedProcessors.forEach { processor ->
logger(processor.renderSpentTime()) logger(processor.renderSpentTime())
} }
logger("Generated files report:")
wrappedProcessors.forEach { processor ->
logger(processor.renderGenerations())
}
} }
private fun dumpProcessorTiming(wrappedProcessors: List<ProcessorWrapper>, apReportFile: File, logger: (String) -> Unit) { private fun dumpProcessorStats(wrappedProcessors: List<ProcessorWrapper>, apReportFile: File, logger: (String) -> Unit) {
logger("Dumping Kapt Annotation Processing performance report to ${apReportFile.absolutePath}") logger("Dumping Kapt Annotation Processing performance report to ${apReportFile.absolutePath}")
apReportFile.writeText(buildString { apReportFile.writeText(buildString {
@@ -260,8 +264,9 @@ private class ProcessorWrapper(private val delegate: IncrementalProcessor) : Pro
numSourcesGenerated = sources?.size ?: -1 numSourcesGenerated = sources?.size ?: -1
} catch (e: Exception) { } catch (e: Exception) {
// Not much we can do // Not much we can do
} finally {
sourcesGenerated.add(numSourcesGenerated)
} }
sourcesGenerated.add(numSourcesGenerated)
} }
} }
+7 -8
View File
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.kapt.cli
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
import org.jetbrains.kotlin.kapt.cli.CliToolOption.Format.* import org.jetbrains.kotlin.kapt.cli.CliToolOption.Format.*
import java.io.File
class CliToolOption(val name: String, val format: Format) { class CliToolOption(val name: String, val format: Format) {
enum class Format { enum class Format {
@@ -174,18 +173,18 @@ enum class KaptCliOption(
cliToolOption = CliToolOption("-Kapt-verbose", FLAG) cliToolOption = CliToolOption("-Kapt-verbose", FLAG)
), ),
SHOW_PROCESSOR_TIMINGS( SHOW_PROCESSOR_STATS(
"showProcessorTimings", "showProcessorStats",
"true | false", "true | false",
"Show processor timings", "Show processor timings",
cliToolOption = CliToolOption("-Kapt-show-processor-timings", FLAG) cliToolOption = CliToolOption("-Kapt-show-processor-stats", FLAG)
), ),
DUMP_PROCESSOR_TIMINGS( DUMP_PROCESSOR_STATS(
"dumpProcessorTimings", "dumpProcessorStats",
"<path>", "<path>",
"Dump processor performance statistics to the specified file", "Dump processor statistics (performance and generations) to the specified file",
cliToolOption = CliToolOption("-Kapt-dump-processor-timings", VALUE) cliToolOption = CliToolOption("-Kapt-dump-processor-stats", VALUE)
), ),
STRICT_MODE_OPTION( STRICT_MODE_OPTION(
@@ -120,8 +120,8 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
STRICT_MODE_OPTION -> setFlag(KaptFlag.STRICT, value) STRICT_MODE_OPTION -> setFlag(KaptFlag.STRICT, value)
STRIP_METADATA_OPTION -> setFlag(KaptFlag.STRIP_METADATA, value) STRIP_METADATA_OPTION -> setFlag(KaptFlag.STRIP_METADATA, value)
KEEP_KDOC_COMMENTS_IN_STUBS -> setFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, value) KEEP_KDOC_COMMENTS_IN_STUBS -> setFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, value)
SHOW_PROCESSOR_TIMINGS -> setFlag(KaptFlag.SHOW_PROCESSOR_TIMINGS, value) SHOW_PROCESSOR_STATS -> setFlag(KaptFlag.SHOW_PROCESSOR_STATS, value)
DUMP_PROCESSOR_TIMINGS -> processorsPerfReportFile = File(value) DUMP_PROCESSOR_STATS -> processorsStatsReportFile = File(value)
INCLUDE_COMPILE_CLASSPATH -> setFlag(KaptFlag.INCLUDE_COMPILE_CLASSPATH, value) INCLUDE_COMPILE_CLASSPATH -> setFlag(KaptFlag.INCLUDE_COMPILE_CLASSPATH, value)
DETECT_MEMORY_LEAKS_OPTION -> setSelector(enumValues<DetectMemoryLeaksMode>(), value) { detectMemoryLeaks = it } DETECT_MEMORY_LEAKS_OPTION -> setSelector(enumValues<DetectMemoryLeaksMode>(), value) { detectMemoryLeaks = it }