Metrics reporting utils

This commit is contained in:
Alexey Tsvetkov
2019-12-16 11:19:59 +03:00
committed by Alexander Likhachev
parent 97a09680d5
commit 5bde6457b1
4 changed files with 82 additions and 2 deletions
@@ -16,4 +16,21 @@ interface ICReporter {
fun reportMarkDirtyClass(affectedFiles: Iterable<File>, classFqName: String)
fun reportMarkDirtyMember(affectedFiles: Iterable<File>, scope: String, name: String)
fun reportMarkDirty(affectedFiles: Iterable<File>, reason: String)
fun startMeasure(metric: String, startNs: Long)
fun endMeasure(metric: String, endNs: Long)
}
fun <T> ICReporter?.measure(metric: String, fn: () -> T): T {
if (this == null) return fn()
val start = System.nanoTime()
startMeasure(metric, start)
try {
return fn()
} finally {
val end = System.nanoTime()
endMeasure(metric, end)
}
}
@@ -33,4 +33,10 @@ abstract class ICReporterBase(private val pathsBase: File? = null) : ICReporter
protected fun File.relativeOrCanonical(): File =
pathsBase?.let { relativeToOrNull(it) } ?: canonicalFile
override fun startMeasure(metric: String, startNs: Long) {
}
override fun endMeasure(metric: String, endNs: Long) {
}
}