Created
October 22, 2014 16:36
-
-
Save dubek/e66579046eb57c589a64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark/ips" | |
require "hamster/set" | |
require "hamster/version" | |
puts "OS Name: #{`uname -s -r -v -m -p -i -o`}" | |
puts "Ruby Version: #{`ruby -v`}" | |
puts "RubyGems Version: #{`gem -v`}" | |
puts "RVM Version: #{`rvm -v`}" | |
puts "Hamster version: #{Hamster::VERSION}" | |
def benchmark_unions(set_size) | |
puts | |
puts | |
puts | |
Benchmark.ips do |b| | |
set_a = Hamster::Set.new((1..set_size).to_a) | |
set_b = Hamster::Set.new(((set_size/2)..(set_size*3/2)).to_a) | |
b.report "old_union(N=#{set_size})" do | |
set_a.old_union(set_b) | |
end | |
b.report "union(N=#{set_size})" do | |
set_a.union(set_b) | |
end | |
b.compare! | |
end | |
end | |
benchmark_unions(10) | |
benchmark_unions(20) | |
benchmark_unions(50) | |
benchmark_unions(100) | |
benchmark_unions(1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS Name: Linux 2.6.32-431.30.1.el6.x86_64 #1 SMP Wed Jul 30 14:44:26 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux | |
Ruby Version: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux] | |
RubyGems Version: 2.2.2 | |
RVM Version: rvm 1.25.33 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/] | |
Hamster version: 1.0.1-rc2 | |
Calculating ------------------------------------- | |
old_union(N=10) 3211 i/100ms | |
union(N=10) 4776 i/100ms | |
------------------------------------------------- | |
old_union(N=10) 36325.8 (±10.8%) i/s - 179816 in 5.040180s | |
union(N=10) 50372.5 (±5.0%) i/s - 253128 in 5.039802s | |
Comparison: | |
union(N=10): 50372.5 i/s | |
old_union(N=10): 36325.8 i/s - 1.39x slower | |
Calculating ------------------------------------- | |
old_union(N=20) 1574 i/100ms | |
union(N=20) 2192 i/100ms | |
------------------------------------------------- | |
old_union(N=20) 16419.8 (±2.1%) i/s - 83422 in 5.082950s | |
union(N=20) 23137.4 (±1.5%) i/s - 116176 in 5.022369s | |
Comparison: | |
union(N=20): 23137.4 i/s | |
old_union(N=20): 16419.8 i/s - 1.41x slower | |
Calculating ------------------------------------- | |
old_union(N=50) 542 i/100ms | |
union(N=50) 721 i/100ms | |
------------------------------------------------- | |
old_union(N=50) 5712.5 (±4.1%) i/s - 28726 in 5.038530s | |
union(N=50) 6704.6 (±6.2%) i/s - 33887 in 5.075477s | |
Comparison: | |
union(N=50): 6704.6 i/s | |
old_union(N=50): 5712.5 i/s - 1.17x slower | |
Calculating ------------------------------------- | |
old_union(N=100) 275 i/100ms | |
union(N=100) 329 i/100ms | |
------------------------------------------------- | |
old_union(N=100) 2808.4 (±9.3%) i/s - 14025 in 5.052939s | |
union(N=100) 3183.0 (±10.5%) i/s - 15792 in 5.031134s | |
Comparison: | |
union(N=100): 3183.0 i/s | |
old_union(N=100): 2808.4 i/s - 1.13x slower | |
Calculating ------------------------------------- | |
old_union(N=1000) 17 i/100ms | |
union(N=1000) 18 i/100ms | |
------------------------------------------------- | |
old_union(N=1000) 194.0 (±10.3%) i/s - 969 in 5.057394s | |
union(N=1000) 199.0 (±7.5%) i/s - 990 in 5.006409s | |
Comparison: | |
union(N=1000): 199.0 i/s | |
old_union(N=1000): 194.0 i/s - 1.03x slower | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment