File: union_bench.rb

package info (click to toggle)
ruby-immutable-ruby 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,852 kB
  • sloc: ruby: 16,556; makefile: 4
file content (15 lines) | stat: -rw-r--r-- 316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'benchmark/ips'
require 'immutable/set'

Benchmark.ips do |b|
  small_set = Immutable::Set.new((1..10).to_a)
  large_set = Immutable::Set.new((1..1000).to_a)

  b.report 'small.union(large)' do
    small_set.union(large_set)
  end

  b.report 'large.union(small)' do
    large_set.union(small_set)
  end
end