Humanity

Edit the world by your favorite way

Scalaでforeachとforとwhileどれで回したら速いのかベンチマーク


ベンチマークとかあまりしたことないし全然あってるか分からないけどとりあえずやってみる。
結果はまぁ当たり前といった感じ。

100000000 times of loop of For
100000000 times of loop of ForEach
100000000 times of loop of ForPrimitive
iterate 100000000 times...
For: 2516 ms
iterate 100000000 times...
ForEach: 3047 ms
iterate 100000000 times...
ForPrimitive: 390 ms

やっぱgistでもScalaは色付けされないか