Skip to content

Instantly share code, notes, and snippets.

@saml
Created June 26, 2013 20:43
Show Gist options
  • Select an option

  • Save saml/5871472 to your computer and use it in GitHub Desktop.

Select an option

Save saml/5871472 to your computer and use it in GitHub Desktop.
timer
private def _t[A](title: String = "")(f: => A): A = {
val t: Long = System.currentTimeMillis()
try {
f
} finally {
Logger.debug(s"${title} took ${(System.currentTimeMillis() - t)/1000.0} secs")
}
}
private def _tf[A](title: String = "")(f: => Future[A]): Future[A] = {
val t: Long = System.currentTimeMillis()
f.onComplete {
case x => Logger.debug(s"${title} took ${(System.currentTimeMillis() - t)/1000.0} secs")
}
f
}
//Usage:
//_t("bleh bleh") { ... }
//_tf("bleh bleh") { future { ... } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment