Skip to content

Instantly share code, notes, and snippets.

@pocke
Created August 20, 2018 00:45
Show Gist options
  • Save pocke/98122fab739c87d47d8ca1867eb19d4b to your computer and use it in GitHub Desktop.
Save pocke/98122fab739c87d47d8ca1867eb19d4b to your computer and use it in GitHub Desktop.
namerror message patch
$ ruby test_before.rb # before patch
3.7357151369942585
$ ruby test.rb # after patch
1.2525334189995192

3.7357151369942585 / 1.2525334189995192 * 1000000 => 2982527.3164992435 times faster!

require 'benchmark'
str = 'a' * 500_000_000
begin
str.a
rescue => ex
p Benchmark.realtime {1000000.times {ex.message} }
end
require 'benchmark'
str = 'a' * 500_000_000
begin
str.a
rescue => ex
p Benchmark.realtime {ex.message }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment