Skip to content

Instantly share code, notes, and snippets.

@jimfulton
Last active December 20, 2015 21:49
Show Gist options
  • Save jimfulton/6200533 to your computer and use it in GitHub Desktop.
Save jimfulton/6200533 to your computer and use it in GitHub Desktop.
Stupid little timer for timing grizzled.io.RichInputStream.copyTo. Meant to be run from the sbt console. sample-session shows a sample session copying a file named "src" to a file named "dest".
bash-3.2$ sbt console
scala> :load streamtimer.scala
scala> f("src", "dest")
def timeit(f: => Unit): Long = {
val t = System.currentTimeMillis()
f
System.currentTimeMillis() - t
}
import grizzled.file.util._
import java.io.File
def f(src: String, dest: String) : Unit = {
val s = new File(src)
val d = new File(dest)
println(timeit { copyFile(s, d) })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment