Last active
August 29, 2015 14:18
-
-
Save korun/1a9a1a42338cb4edfda1 to your computer and use it in GitHub Desktop.
Revisions
-
korun revised this gist
Apr 2, 2015 . 1 changed file with 4 additions and 3 deletions.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 @@ -2,6 +2,7 @@ n = 1_000_000 login = 'login' time = Time.now.to_i Benchmark.bmbm 20 do |results| @@ -13,21 +14,21 @@ # result: 3 array object usage results.report '[] + []' do n.times do [login, time] + [3, 4, 5] end end # result: 2 array object usage results.report '[].push(*[])' do n.times do [login, time].push(*[3, 4, 5]) end end # result: 1 array object usage results.report '[].unshift(a, b)' do n.times do [3, 4, 5].unshift(login, time) end end end -
korun created this gist
Apr 2, 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,33 @@ require 'benchmark' n = 1_000_000 time = Time.now.to_i Benchmark.bmbm 20 do |results| results.report 'cycle' do n.times do end end # result: 3 array object usage results.report '[] + []' do n.times do ['login', time] + [3, 4, 5] end end # result: 2 array object usage results.report '[].push(*[])' do n.times do ['login', time].push(*[3, 4, 5]) end end # result: 1 array object usage results.report '[].unshift(a, b)' do n.times do [3, 4, 5].unshift('login', time) end end end