Sha256: 60aaeccb37c8de65a98af2f11e64667b56f60da06274961bf636c3aa197e0df3
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
class VariablesBench < SortedBench setup do LETTERS = (Array("a".."z")+Array("A".."Z")) N = 1_000 # N = 10_000 # N = 100_000 log "setup N = #{N}" end mark "local variable" do i = 0 a = nil while (i += 1) <= N eval "v_#{random_name} = sample" end end mark "instance variable" do i = 0 while (i += 1) <= N eval "@v_#{random_name} = sample" end end mark "class variable" do i = 0 while (i += 1) <= N eval "@@v_#{random_name} = sample" end end mark "global variable" do i = 0 while (i += 1) <= N eval "$v_#{random_name} = sample" end end # helper methods def self.random_name LETTERS.shuffle.join("") end def self.sample LETTERS.sample end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lizarb-1.0.4 | app_new/dev/benches/variables_bench.rb |