Created
January 27, 2015 00:52
-
-
Save pd/46b0ab95f45cabdc70de to your computer and use it in GitHub Desktop.
rbx -v == rubinius 2.5.0.n24 (2.1.0 af7eb1b4 2015-01-24 3.5.0 JI) [x86_64-darwin14.0.0]
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' | |
SYM = :magic_key | |
MYS = :key_magic | |
STR = 'magic_key' | |
RTS = 'key_magic' | |
Benchmark.ips do |x| | |
x.config(time: 2, warmup: 1) | |
x.report('Symbol#==') do | |
SYM == SYM | |
end | |
x.report('Symbol#!=') do | |
SYM == MYS | |
end | |
x.report('String#==') do | |
STR == STR | |
end | |
x.report('String#!=') do | |
STR == RTS | |
end | |
x.compare! | |
end |
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
~ [rb:rbx-2.5.99] » ruby foo.rb | |
Calculating ------------------------------------- | |
Symbol#== 222.090k i/100ms | |
Symbol#!= 228.315k i/100ms | |
String#== 393.554k i/100ms | |
String#!= 391.007k i/100ms | |
------------------------------------------------- | |
Symbol#== 7.280M (± 1.7%) i/s - 14.658M | |
Symbol#!= 3.225M (± 1.8%) i/s - 6.621M | |
String#== 7.003M (± 2.1%) i/s - 14.168M | |
String#!= 7.207M (± 1.4%) i/s - 14.467M | |
Comparison: | |
Symbol#==: 7279570.8 i/s | |
String#!=: 7207471.8 i/s - 1.01x slower | |
String#==: 7002508.7 i/s - 1.04x slower | |
Symbol#!=: 3225177.3 i/s - 2.26x slower | |
~ [rb:rbx-2.5.99] » RBXOPT=-Xint ruby foo.rb | |
Calculating ------------------------------------- | |
Symbol#== 141.790k i/100ms | |
Symbol#!= 86.057k i/100ms | |
String#== 148.336k i/100ms | |
String#!= 150.662k i/100ms | |
------------------------------------------------- | |
Symbol#== 3.590M (± 3.3%) i/s - 7.231M | |
Symbol#!= 1.457M (± 2.3%) i/s - 2.926M | |
String#== 4.067M (± 1.2%) i/s - 8.158M | |
String#!= 4.123M (± 1.0%) i/s - 8.286M | |
Comparison: | |
String#!=: 4123026.8 i/s | |
String#==: 4067338.6 i/s - 1.01x slower | |
Symbol#==: 3589855.0 i/s - 1.15x slower | |
Symbol#!=: 1456970.2 i/s - 2.83x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment