Skip to content

Commit

Permalink
Add benchmark for Array#combination
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Apr 7, 2012
1 parent 95b44bb commit 85b4464
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions benchmark/core/array/bench_combination.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 85b4464

Please sign in to comment.