au.csiro.pbdava.ssparkle.common.utils.Prof.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of variant-spark_2.11 Show documentation
Show all versions of variant-spark_2.11 Show documentation
Genomic variants interpretation toolkit
The newest version!
package au.csiro.pbdava.ssparkle.common.utils
trait Prof extends Logging {
lazy val profEnable: Boolean = System.getProperty("sparkle.prof", "false").toBoolean
var prevStartTime: Long = 0L
def profReset(): Unit = if (!profEnable) {} else {
prevStartTime = System.currentTimeMillis()
}
def profPoint(msg: => String): Unit = if (!profEnable) {} else {
val duration = System.currentTimeMillis() - prevStartTime
logInfo(s"${msg}: ${duration}")
profReset()
}
def profIt[R](msg: => String)(f: => R): R =
if (!profEnable) f
else {
val st = System.currentTimeMillis()
val r = f
val duration = System.currentTimeMillis() - st
logInfo(s"${msg}: ${duration}")
r
}
}