object Tak{
def tak(x:Int, y:Int,z:Int):Int = if (y >= x) z else tak(tak(x-1, y, z),tak(y-1, z, x),tak(z-1, x, y))
def main(args:Array[String]) = {
0 until 1000 foreach ((i) => tak(24,16,8))
}
}
Here are the results for JavaFX on my MacBook:
$ time javafx -server -cp . tak
real 0m12.847s
user 0m11.926s
sys 0m0.338s
So my system is a little slower than Chris Oliver's. That's why I had to run his bench on my MacBook first, to make a fair comparison to the Scala version. Here are those results.
$ time scala Tak
real 0m9.690s
user 0m9.122s
sys 0m0.261s
Scala not only beat out JavaFX on my system, but was also faster than JavaFX running on Chris Oliver's faster system. The guys at Sun should have never let Odersky go!
1 comment:
I do not know what is :Int,z:Int):Int = if (y >= x) z else tak(tak(x-1, y, z),tak(y-1, z, x),tak(z-1, x, y))
def main(args:Array[String]) = {
0 until 1000 foreach ((i
Post a Comment