Last active
December 31, 2015 17:49
Revisions
-
akshay-vishnoi revised this gist
Dec 18, 2013 . 1 changed file with 0 additions and 1 deletion.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 @@ -6,7 +6,6 @@ def old_many?(enum) end def new_many?(enum) enum.count > 1 end -
akshay-vishnoi revised this gist
Dec 18, 2013 . No changes.There are no files selected for viewing
-
akshay-vishnoi renamed this gist
Dec 18, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
akshay-vishnoi revised this gist
Dec 18, 2013 . No changes.There are no files selected for viewing
-
akshay-vishnoi created this gist
Dec 18, 2013 .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,31 @@ require 'benchmark/ips' def old_many?(enum) cnt = 0 enum.any? { (cnt += 1) > 1 } end def new_many?(enum) cnt = 0 enum.count > 1 end enum = (1..1000).to_a Benchmark.ips do |b| b.report('old') do old_many? enum end b.report('new') do new_many? enum end end # Output # Calculating ------------------------------------- # old 57932 i/100ms # new 93881 i/100ms # ------------------------------------------------- # old 1312923.5 (±3.1%) i/s - 6604248 in 5.035705s # new 4991185.8 (±3.2%) i/s - 24972346 in 5.009269s