summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/util/package.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-27 22:53:15 +0000
committerPaul Phillips <paulp@improving.org>2010-11-27 22:53:15 +0000
commit25757de1db52311a94ed2672639c0f09fc28c31a (patch)
tree8a47cdfa32681dd22a2d7afedaa9615ff351aeb8 /src/compiler/scala/tools/nsc/util/package.scala
parent49d47cb3723c9d3160e3f215808b571a05d1b252 (diff)
downloadscala-25757de1db52311a94ed2672639c0f09fc28c31a.tar.gz
scala-25757de1db52311a94ed2672639c0f09fc28c31a.tar.bz2
scala-25757de1db52311a94ed2672639c0f09fc28c31a.zip
Some cleanups in the *Runners and a few compile...
Some cleanups in the *Runners and a few compiler I/O conveniences. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/package.scala')
-rw-r--r--src/compiler/scala/tools/nsc/util/package.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala
index 7924d4debd..800cb75b97 100644
--- a/src/compiler/scala/tools/nsc/util/package.scala
+++ b/src/compiler/scala/tools/nsc/util/package.scala
@@ -46,6 +46,18 @@ package object util {
result
}
+ /** Given a function and a block of code, evaluates code block,
+ * calls function with milliseconds elapsed, and returns block result.
+ */
+ def millisElapsedTo[T](f: Long => Unit)(body: => T): T = {
+ val start = System.currentTimeMillis
+ val result = body
+ val end = System.currentTimeMillis
+
+ f(end - start)
+ result
+ }
+
/** Generate a string using a routine that wants to write on a stream. */
def stringFromWriter(writer: PrintWriter => Unit): String = {
val stringWriter = new StringWriter()