Created
June 26, 2013 20:43
-
-
Save saml/5871472 to your computer and use it in GitHub Desktop.
timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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