-
-
Notifications
You must be signed in to change notification settings - Fork 924
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6031 from kares/fix-rescue-nil-perf
[fix] restore rescue nil performance
- Loading branch information
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'benchmark/ips' | ||
|
||
Benchmark.ips do |x| | ||
|
||
x.config(:time => 10, :warmup => 10) | ||
|
||
x.report("raise(msg) default") do | ||
begin | ||
raise 'default' | ||
rescue => ex | ||
ex && true | ||
end | ||
end | ||
|
||
x.report("raise(class, msg)") do | ||
begin | ||
raise RuntimeError, 'def' | ||
rescue => ex | ||
ex && true | ||
end | ||
end | ||
|
||
x.report("raise(class, msg, nil)") do | ||
begin | ||
raise RuntimeError, 'nil', nil | ||
rescue => ex | ||
ex && true | ||
end | ||
end | ||
|
||
trace = caller.dup | ||
x.report("raise(class, msg, trace)") do | ||
begin | ||
raise RuntimeError, 'nil', backtrace | ||
rescue => ex | ||
ex && true | ||
end | ||
end | ||
|
||
x.report("raise(class, msg) rescue nil") do | ||
(raise RuntimeError, 'def') rescue nil | ||
end | ||
|
||
x.report("raise(class, msg, trace) rescue nil") do | ||
(raise RuntimeError, 'def', trace) rescue nil | ||
end | ||
|
||
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
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