Created
August 8, 2016 11:25
-
-
Save caius/a671cab1f8f15513df372edc0f87f2f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "rdl" | |
def sum(a, b) | |
a + b | |
end | |
type '(Fixnum, Fixnum) -> Fixnum' | |
def sum_rdl(a, b) | |
a + b | |
end | |
Benchmark.ips do |results| | |
results.report("sum ok") { sum(1, 5) } | |
results.report("sum fail") { sum(true, false) rescue nil } | |
results.report("sum_rdl ok") { sum_rdl(1, 5) } | |
results.report("sum_rdl fail") { sum_rdl(true, false) rescue nil } | |
end | |
__END__ | |
Warming up -------------------------------------- | |
sum ok 246.345k i/100ms | |
sum fail 38.719k i/100ms | |
sum_rdl ok 7.752k i/100ms | |
sum_rdl fail 5.792k i/100ms | |
Calculating ------------------------------------- | |
sum ok 9.040M (± 7.9%) i/s - 44.835M in 5.002876s | |
sum fail 444.530k (± 7.4%) i/s - 2.246M in 5.084312s | |
sum_rdl ok 79.555k (±10.3%) i/s - 395.352k in 5.046667s | |
sum_rdl fail 59.882k (± 4.4%) i/s - 301.184k in 5.039990s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment