diff --git a/_benchmark/tarai.rb b/_benchmark/tarai.rb index ff64ad23..f0b99cfd 100644 --- a/_benchmark/tarai.rb +++ b/_benchmark/tarai.rb @@ -28,26 +28,31 @@ def tarai(x, y, z) = system("go version", exception: true) +MAX_BENCH_COUNT = 4 + Benchmark.ips do |x| - # sequential version - x.report("sequential"){ 4.times{ tarai(14, 7, 0) } } + # Ruby: sequential version + x.report("Ruby: sequential"){ MAX_BENCH_COUNT.times{ tarai(14, 7, 0) } } - # parallel version (with Ractor) - x.report("parallel (Ractor)"){ - 4.times.map do + # Ruby: parallel version (with Ractor) + x.report("Ruby: Ractor"){ + MAX_BENCH_COUNT.times.map do Ractor.new { tarai(14, 7, 0) } end.each(&:take) } - # parallel version (with Fiber) - x.report("parallel (Fiber)"){ - 4.times.map do + # Ruby: parallel version (with Fiber) + x.report("Ruby: Fiber"){ + MAX_BENCH_COUNT.times.map do Fiber.new { tarai(14, 7, 0) } end.each(&:resume) } - # parallel version (with goroutine) - x.report("parallel (goroutine)"){ Example::Benchmark.tarai_goroutine(14, 7, 0, 4) } + # Go: sequential version + x.report("Go: sequential"){ MAX_BENCH_COUNT.times{ Example::Benchmark.tarai(14, 7, 0) } } + + # Go: parallel version (with goroutine) + x.report("Go: goroutine"){ Example::Benchmark.tarai_goroutine(14, 7, 0, MAX_BENCH_COUNT) } x.compare! end