diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-15 13:27:25 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-15 13:27:25 -0800 |
commit | 51a433c8acff390a0109d92de222c9f8361b0bcf (patch) | |
tree | d04eba40f342e3bde323c6b41ce970fb77e9a34e /core/src | |
parent | 50aabeaf229e939b2189067c3ea9ce284d538328 (diff) | |
download | mill-51a433c8acff390a0109d92de222c9f8361b0bcf.tar.gz mill-51a433c8acff390a0109d92de222c9f8361b0bcf.tar.bz2 mill-51a433c8acff390a0109d92de222c9f8361b0bcf.zip |
Properly time entire main method
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index 87395113..f3af640f 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -14,8 +14,15 @@ import scala.annotation.tailrec import ammonite.main.Scripts.pathScoptRead import ammonite.repl.Repl object Main { - def apply[T: Discovered](args: Seq[String], obj: T, watch: Path => Unit) = { + def timed[T](t: => T) = { val startTime = System.currentTimeMillis() + val res = t + val delta = System.currentTimeMillis() - startTime + println(fansi.Color.Blue("Finished in " + delta/1000.0 + "s")) + res + } + def apply[T: Discovered](args: Seq[String], obj: T, watch: Path => Unit) = { + val Seq(selectorString, rest @_*) = args val selector = selectorString.split('.') val discovered = implicitly[Discovered[T]] @@ -35,8 +42,7 @@ object Main { val evaluator = new Evaluator(workspacePath, mapping) val evaluated = evaluator.evaluate(OSet(target)) - val delta = System.currentTimeMillis() - startTime - println(fansi.Color.Blue("Finished in " + delta/1000.0 + "s")) + evaluated.transitive.foreach{ case t: define.Source => watch(t.handle.path) case _ => // do nothing @@ -61,7 +67,7 @@ object Main { } - def main(args: Array[String]): Unit = { + def main(args: Array[String]): Unit = timed{ case class Config(home: ammonite.ops.Path = pwd/'out/'ammonite, colored: Option[Boolean] = None, help: Boolean = false, |