From 85b446452dca38bf5bc31a634bbf0b18d4bd4edb Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Sat, 7 Apr 2012 18:19:33 +0200 Subject: [PATCH] Add benchmark for Array#combination --- benchmark/core/array/bench_combination.rb | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 benchmark/core/array/bench_combination.rb diff --git a/benchmark/core/array/bench_combination.rb b/benchmark/core/array/bench_combination.rb new file mode 100644 index 0000000000..42d1a3fa98 --- /dev/null +++ b/benchmark/core/array/bench_combination.rb @@ -0,0 +1,24 @@ +require 'benchmark' +require 'benchmark/ips' +require File.expand_path('../shared_array.rb', __FILE__) + +Benchmark.ips do |x| + small_array = $small_array.dup + + x.report "combination by groups of 2" do |times| + i = 0 + while i < times + small_array.combination(2).to_a + i += 1 + end + end + + x.report "combination by groups of 4" do |times| + i = 0 + while i < times + small_array.combination(4).to_a + i += 1 + end + end + +end