-
Notifications
You must be signed in to change notification settings - Fork 3
07 Measuring the execution time
Vladyslav Pekker edited this page Dec 26, 2015
·
11 revisions
In the MiscModule spells defines miscellaneous utility methods, which are too small for a distinctive module. Among them is measureExecutionTime[T](expression: => T): (T, Duration)
:
scala> def fetchTheAnswer(): Int = {
| Thread.sleep(3000)
|
| 42
| }
fetchTheAnswer: ()Int
scala> val result @ (theAnswer, duration) = measureExecutionTime(fetchTheAnswer)
result: (Int, scala.concurrent.duration.Duration) = (42,3000178505 nanoseconds)
theAnswer: Int = 42
duration: scala.concurrent.duration.Duration = 3000178505 nanoseconds
The defaults can be found in the reference.conf file and the Configuration wiki page shows how to override as well as retrieve them programmatically.