Created
April 24, 2013 11:24
-
-
Save noelmarkham/5451442 to your computer and use it in GitHub Desktop.
Scala console power mode
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
scala> :power | |
** Power User mode enabled - BEEP BOOP SPIZ ** | |
** :phase has been set to 'typer'. ** | |
** scala.tools.nsc._ has been imported ** | |
** global._ and definitions._ also imported ** | |
** Try :help, vals.<tab>, power.<tab> ** | |
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
def time[T](fn: =>T): T = { | |
val start = System.currentTimeMillis | |
val ret = fn | |
println("Run in %d millis".format(System.currentTimeMillis - start)) | |
ret | |
} | |
// Exiting paste mode, now interpreting. | |
time: [T](fn: => T)T | |
scala> :wrap time | |
Set wrapper to 'time' | |
scala> (1 to 1000000) reduceLeft (_ + _) | |
Run in 19 millis | |
res0: Int = 1784293664 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment