mirror of https://github.com/sbt/sbt.git
New option sbt.task.timings.omit.paths, to produce even cleaner reports.
This commit is contained in:
parent
6ab0bc403a
commit
618487eb58
|
|
@ -21,6 +21,7 @@ private[sbt] final class TaskTimings(shutdown: Boolean) extends ExecuteProgress[
|
||||||
private[this] val timings = new ConcurrentHashMap[Task[_], Long]
|
private[this] val timings = new ConcurrentHashMap[Task[_], Long]
|
||||||
private[this] var start = 0L
|
private[this] var start = 0L
|
||||||
private[this] val threshold = java.lang.Long.getLong("sbt.task.timings.threshold", 0L)
|
private[this] val threshold = java.lang.Long.getLong("sbt.task.timings.threshold", 0L)
|
||||||
|
private[this] val omitPaths = java.lang.Boolean.getBoolean("sbt.task.timings.omit.paths")
|
||||||
private[this] val (unit, divider) = System.getProperty("sbt.task.timings.unit", "ms") match {
|
private[this] val (unit, divider) = System.getProperty("sbt.task.timings.unit", "ms") match {
|
||||||
case "ns" => ("ns", 0)
|
case "ns" => ("ns", 0)
|
||||||
case "us" => ("µs", 3)
|
case "us" => ("µs", 3)
|
||||||
|
|
@ -59,6 +60,8 @@ private[sbt] final class TaskTimings(shutdown: Boolean) extends ExecuteProgress[
|
||||||
report()
|
report()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val reFilePath = raw"\{[^}]+\}".r
|
||||||
|
|
||||||
private[this] def report() = {
|
private[this] def report() = {
|
||||||
val total = divide(System.nanoTime - start)
|
val total = divide(System.nanoTime - start)
|
||||||
println(s"Total time: $total $unit")
|
println(s"Total time: $total $unit")
|
||||||
|
|
@ -66,8 +69,10 @@ private[sbt] final class TaskTimings(shutdown: Boolean) extends ExecuteProgress[
|
||||||
def sumTimes(in: Seq[(Task[_], Long)]) = in.map(_._2).sum
|
def sumTimes(in: Seq[(Task[_], Long)]) = in.map(_._2).sum
|
||||||
val timingsByName = timings.asScala.toSeq.groupBy { case (t, time) => mappedName(t) } mapValues (sumTimes)
|
val timingsByName = timings.asScala.toSeq.groupBy { case (t, time) => mappedName(t) } mapValues (sumTimes)
|
||||||
val times = timingsByName.toSeq.sortBy(_._2).reverse
|
val times = timingsByName.toSeq.sortBy(_._2).reverse
|
||||||
.map { case (name, time) => (name, divide(time)) }
|
.map {
|
||||||
.filter { _._2 > threshold }
|
case (name, time) =>
|
||||||
|
(if (omitPaths) reFilePath.replaceFirstIn(name, "") else name, divide(time))
|
||||||
|
}.filter { _._2 > threshold }
|
||||||
if (times.size > 0) {
|
if (times.size > 0) {
|
||||||
val maxTaskNameLength = times.map { _._1.length }.max
|
val maxTaskNameLength = times.map { _._1.length }.max
|
||||||
val maxTime = times.map { _._2 }.max.toString.length
|
val maxTime = times.map { _._2 }.max.toString.length
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue