Created
December 25, 2015 11:56
-
-
Save mtkd/c0e40a0d367fd8488b30 to your computer and use it in GitHub Desktop.
Revisions
-
mtkd created this gist
Dec 25, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Test perf difference between try and safe navigator in Ruby 2.3.0 require 'benchmark' require 'active_support' require 'active_support/core_ext/object' Benchmark.bm do |x| obj = 0 x.report { 10000.times do; obj.try(:to_s); end; } x.report { 10000.times do; obj&.to_s; end; } end # user system total real # 0.010000 0.000000 0.010000 ( 0.005675) # 0.000000 0.000000 0.000000 ( 0.000844)