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
/**
* 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.
@@ -118,4 +118,4 @@ interface KaptJavacOption {
* Adds an option with name only (no value associated).
*/
fun option(name: Any)
}
}
@@ -491,7 +491,7 @@ class Kapt3GradleSubplugin @Inject internal constructor(private val registry: To
)
pluginOptions += SubpluginOption("stripMetadata", "${kaptExtension.stripMetadata}")
pluginOptions += SubpluginOption("keepKdocCommentsInStubs", "${project.isKaptKeepKdocCommentsInStubs()}")
pluginOptions += SubpluginOption("showProcessorTimings", "${kaptExtension.showProcessorTimings}")
pluginOptions += SubpluginOption("showProcessorStats", "${kaptExtension.showProcessorStats}")
pluginOptions += SubpluginOption("detectMemoryLeaks", kaptExtension.detectMemoryLeaks)
pluginOptions += SubpluginOption("infoAsWarnings", "${project.isInfoAsWarnings()}")
pluginOptions += FilesSubpluginOption("stubs", listOf(getKaptStubsDir()))
@@ -40,7 +40,7 @@ open class KaptExtension: KaptExtensionConfig {
override var stripMetadata: Boolean = false
override var showProcessorTimings: Boolean = false
override var showProcessorStats: Boolean = false
override var detectMemoryLeaks: String = "default"
@@ -43,7 +43,7 @@ class KaptOptions(
val processingClassLoader: ClassLoader?,
//construct new classloader for these processors instead of using one defined in processingClassLoader
val separateClassloaderForProcessors: Set<String>,
val processorsPerfReportFile: File?
val processorsStatsReportFile: File?
) : KaptFlags {
override fun get(flag: KaptFlag) = flags[flag]
@@ -73,7 +73,7 @@ class KaptOptions(
var mode: AptMode = AptMode.WITH_COMPILATION
var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT
var processorsPerfReportFile: File? = null
var processorsStatsReportFile: File? = null
fun build(): KaptOptions {
val sourcesOutputDir = this.sourcesOutputDir ?: error("'sourcesOutputDir' must be set")
@@ -88,7 +88,7 @@ class KaptOptions(
mode, detectMemoryLeaks,
processingClassLoader = null,
separateClassloaderForProcessors = emptySet(),
processorsPerfReportFile = processorsPerfReportFile
processorsStatsReportFile = processorsStatsReportFile
)
}
}
@@ -114,7 +114,7 @@ interface KaptFlags {
}
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"),
INFO_AS_WARNINGS("Info as warnings"),
USE_LIGHT_ANALYSIS("Use light analysis", defaultValue = true),
@@ -116,13 +116,13 @@ fun KaptContext.doAnnotationProcessing(
logger.info("Annotation processing complete, errors: $errorCount, warnings: $warningCount")
}
val showProcessorTimings = options[KaptFlag.SHOW_PROCESSOR_TIMINGS]
if (logger.isVerbose || showProcessorTimings) {
val loggerFun = if (showProcessorTimings) logger::warn else logger::info
showProcessorTimings(wrappedProcessors, loggerFun)
val showProcessorStats = options[KaptFlag.SHOW_PROCESSOR_STATS]
if (logger.isVerbose || showProcessorStats) {
val loggerFun = if (showProcessorStats) logger::warn else logger::info
showProcessorStats(wrappedProcessors, loggerFun)
}
options.processorsPerfReportFile?.let { dumpProcessorTiming(wrappedProcessors, options.processorsPerfReportFile, logger::info) }
options.processorsStatsReportFile?.let { dumpProcessorStats(wrappedProcessors, it, logger::info) }
if (logger.isVerbose) {
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:")
wrappedProcessors.forEach { processor ->
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}")
apReportFile.writeText(buildString {
@@ -260,8 +264,9 @@ private class ProcessorWrapper(private val delegate: IncrementalProcessor) : Pro
numSourcesGenerated = sources?.size ?: -1
} catch (e: Exception) {
// 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.kapt.cli.CliToolOption.Format.*
import java.io.File
class CliToolOption(val name: String, val format: Format) {
enum class Format {
@@ -174,18 +173,18 @@ enum class KaptCliOption(
cliToolOption = CliToolOption("-Kapt-verbose", FLAG)
),
SHOW_PROCESSOR_TIMINGS(
"showProcessorTimings",
SHOW_PROCESSOR_STATS(
"showProcessorStats",
"true | false",
"Show processor timings",
cliToolOption = CliToolOption("-Kapt-show-processor-timings", FLAG)
cliToolOption = CliToolOption("-Kapt-show-processor-stats", FLAG)
),
DUMP_PROCESSOR_TIMINGS(
"dumpProcessorTimings",
DUMP_PROCESSOR_STATS(
"dumpProcessorStats",
"<path>",
"Dump processor performance statistics to the specified file",
cliToolOption = CliToolOption("-Kapt-dump-processor-timings", VALUE)
"Dump processor statistics (performance and generations) to the specified file",
cliToolOption = CliToolOption("-Kapt-dump-processor-stats", VALUE)
),
STRICT_MODE_OPTION(
@@ -120,8 +120,8 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
STRICT_MODE_OPTION -> setFlag(KaptFlag.STRICT, value)
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)
SHOW_PROCESSOR_STATS -> setFlag(KaptFlag.SHOW_PROCESSOR_STATS, value)
DUMP_PROCESSOR_STATS -> processorsStatsReportFile = File(value)
INCLUDE_COMPILE_CLASSPATH -> setFlag(KaptFlag.INCLUDE_COMPILE_CLASSPATH, value)
DETECT_MEMORY_LEAKS_OPTION -> setSelector(enumValues<DetectMemoryLeaksMode>(), value) { detectMemoryLeaks = it }