dcsobral/scala — comment on commit 232e81b7daac9d90fb7532b9d6ea8ef7a4ceb1ab
File:  line 0
By dcsobral:

And, just to make it clear what I meant by the overhead of small for loops being heavy, here's data comparing while loops, "tfor" which is a recursive function abstracting for loops, and for loops.

[info] 0% Scenario{vm=java, trial=0, benchmark=Foreach, length=10} 102.02 ns; σ=2.78 ns @ 10 trials
[info] 8% Scenario{vm=java, trial=0, benchmark=TFor, length=10} 6.73 ns; σ=0.53 ns @ 10 trials
[info] 17% Scenario{vm=java, trial=0, benchmark=While, length=10} 6.71 ns; σ=0.04 ns @ 3 trials
[info] 25% Scenario{vm=java, trial=0, benchmark=Foreach, length=100} 173.37 ns; σ=3.24 ns @ 10 trials
[info] 33% Scenario{vm=java, trial=0, benchmark=TFor, length=100} 45.66 ns; σ=0.75 ns @ 10 trials
[info] 42% Scenario{vm=java, trial=0, benchmark=While, length=100} 39.91 ns; σ=0.22 ns @ 3 trials
[info] 50% Scenario{vm=java, trial=0, benchmark=Foreach, length=1000} 840.66 ns; σ=2.12 ns @ 3 trials
[info] 58% Scenario{vm=java, trial=0, benchmark=TFor, length=1000} 418.45 ns; σ=2.79 ns @ 3 trials
[info] 67% Scenario{vm=java, trial=0, benchmark=While, length=1000} 407.88 ns; σ=5.92 ns @ 10 trials
[info] 75% Scenario{vm=java, trial=0, benchmark=Foreach, length=10000} 7601.37 ns; σ=86.44 ns @ 10 trials
[info] 83% Scenario{vm=java, trial=0, benchmark=TFor, length=10000} 4162.84 ns; σ=41.19 ns @ 7 trials
[info] 92% Scenario{vm=java, trial=0, benchmark=While, length=10000} 3894.45 ns; σ=966.35 ns @ 10 trials