Metrics reporting utils
This commit is contained in:
committed by
Alexander Likhachev
parent
97a09680d5
commit
5bde6457b1
@@ -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) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user