Skip to content

Instantly share code, notes, and snippets.

@noelmarkham
Created April 24, 2013 11:24
Show Gist options
  • Save noelmarkham/5451442 to your computer and use it in GitHub Desktop.
Save noelmarkham/5451442 to your computer and use it in GitHub Desktop.
Scala console power mode
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