Last active
August 29, 2015 14:24
-
-
Save cb372/aa4f23e925f133375345 to your computer and use it in GitHub Desktop.
Timing scalac phases
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
import scala.annotation.tailrec | |
class Hello { | |
val foo = "abc" | |
def bar(a: String) = foo + a | |
def fib(n: Int) = { | |
@tailrec | |
def fibRec(n: Int, a:Int, b:Int): Int = n match { | |
case 0 => a | |
case _ => fibRec(n-1, b, a+b) | |
} | |
fibRec(n, 0, 1) | |
} | |
} |
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
$ for p in parser typer tailcalls flatten icode jvm; do | |
echo "Running up to and including phase $p" | |
time scalac -Ystop-after:$p Hello.scala | |
done | |
Running up to and including phase parser | |
scalac -Ystop-after:$p Hello.scala 2.87s user 0.19s system 210% cpu 1.453 total | |
Running up to and including phase typer | |
scalac -Ystop-after:$p Hello.scala 5.71s user 0.31s system 246% cpu 2.444 total | |
Running up to and including phase tailcalls | |
scalac -Ystop-after:$p Hello.scala 6.50s user 0.33s system 258% cpu 2.639 total | |
Running up to and including phase flatten | |
scalac -Ystop-after:$p Hello.scala 8.54s user 0.36s system 276% cpu 3.214 total | |
Running up to and including phase icode | |
scalac -Ystop-after:$p Hello.scala 8.63s user 0.36s system 273% cpu 3.284 total | |
Running up to and including phase jvm | |
scalac -Ystop-after:$p Hello.scala 8.80s user 0.41s system 271% cpu 3.398 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment