KengoTODA / wish-list

issue list as a public todo list
1 stars 0 forks source link

Performance comparison for for-loop and tail call in Java8 #6

Closed KengoTODA closed 9 years ago

KengoTODA commented 9 years ago

Tail call looks good, but I want to compare its performance with legacy way (for-loop).

KengoTODA commented 9 years ago

benchmark result

The for-loop is x1.09~1.15 faster than the tail-call.

# Run complete. Total time: 00:28:07

Benchmark                       Mode  Cnt   Score   Error  Units
MyBenchmark.forLoopFactorial   thrpt  200  41.293 ± 0.205  ops/s
MyBenchmark.tailCallFactorial  thrpt  200  35.976 ± 0.145  ops/s
MyBenchmark.forLoopFibonacci   thrpt  200   6.402 ± 0.168  ops/s
MyBenchmark.tailCallFibonacci  thrpt  200   5.869 ± 0.144  ops/s