Last active
March 7, 2023 22:35
-
-
Save narma/5ffa9e9a81aa2c2acd67c2d81ac0949c to your computer and use it in GitHub Desktop.
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
def time[R](what: String)(block: => R): R = { | |
val t0 = java.lang.System.nanoTime() | |
val result = block | |
val ms = (java.lang.System.nanoTime() - t0) / 10e5.toInt | |
println(s"$what completed. Time elapsed: ${ms}ms") | |
result | |
} | |
def t[R](block: => R): R = { | |
val t0 = java.lang.System.nanoTime() | |
val result = block | |
val ms = (java.lang.System.nanoTime() - t0) / 10e5.toInt | |
println(s"Time elapsed: ${ms}ms") | |
result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment