Skip to content

Commit

Permalink
benchmark/vm1_*.yml: abstract away the while loop
Browse files Browse the repository at this point in the history
benchmark/driver.rb had removed the cost for while loop in benchmark/bm_vm1_*.rb,
and benchmark_driver.gem can achieve the same thing with `loop_count`.

But unfortunately current benchmark_driver.gem can't solve it only for vm1_yield.yml...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
k0kubun committed Jul 8, 2018
1 parent 9e62c93 commit 820ad9c
Show file tree
Hide file tree
Showing 30 changed files with 241 additions and 335 deletions.
6 changes: 2 additions & 4 deletions benchmark/driver.rb
Expand Up @@ -73,15 +73,13 @@ def files
next if @pattern && /#{@pattern}/ !~ File.basename(file)
next if @exclude && /#{@exclude}/ =~ File.basename(file)
case file
when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/
when /bm_(vm2)_/, /bm_loop_(whileloop2).rb/
flag[$1] = true
end
file
}.compact

if flag['vm1'] && !flag['whileloop']
files << File.join(@dir, 'bm_loop_whileloop.rb')
elsif flag['vm2'] && !flag['whileloop2']
if flag['vm2'] && !flag['whileloop2']
files << File.join(@dir, 'bm_loop_whileloop2.rb')
end

Expand Down
27 changes: 12 additions & 15 deletions benchmark/vm1_attr_ivar.yml
@@ -1,17 +1,14 @@
prelude: |
class C
attr_reader :a, :b
def initialize
@a = nil
@b = nil
end
end
obj = C.new
benchmark:
vm1_attr_ivar: |
class C
attr_reader :a, :b
def initialize
@a = nil
@b = nil
end
end
obj = C.new
i = 0
while i<30_000_000 # while loop 1
i += 1
j = obj.a
k = obj.b
end
loop_count: 1
j = obj.a
k = obj.b
loop_count: 30000000
27 changes: 12 additions & 15 deletions benchmark/vm1_attr_ivar_set.yml
@@ -1,17 +1,14 @@
prelude: |
class C
attr_accessor :a, :b
def initialize
@a = nil
@b = nil
end
end
obj = C.new
benchmark:
vm1_attr_ivar_set: |
class C
attr_accessor :a, :b
def initialize
@a = nil
@b = nil
end
end
obj = C.new
i = 0
while i<30_000_000 # while loop 1
i += 1
obj.a = 1
obj.b = 2
end
loop_count: 1
obj.a = 1
obj.b = 2
loop_count: 30000000
18 changes: 7 additions & 11 deletions benchmark/vm1_block.yml
@@ -1,13 +1,9 @@
prelude: |
def m
yield
end
benchmark:
vm1_block: |
def m
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{
}
end
loop_count: 1
m{
}
loop_count: 30000000
15 changes: 6 additions & 9 deletions benchmark/vm1_blockparam.yml
@@ -1,11 +1,8 @@
prelude: |
def m &b
end
benchmark:
vm1_blockparam: |
def m &b
end
vm1_blockparam: 'm{}
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end
loop_count: 1
'
loop_count: 30000000
17 changes: 7 additions & 10 deletions benchmark/vm1_blockparam_call.yml
@@ -1,12 +1,9 @@
prelude: |
def m &b
b.call
end
benchmark:
vm1_blockparam_call: |
def m &b
b.call
end
vm1_blockparam_call: 'm{}
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end
loop_count: 1
'
loop_count: 30000000
25 changes: 11 additions & 14 deletions benchmark/vm1_blockparam_pass.yml
@@ -1,16 +1,13 @@
benchmark:
vm1_blockparam_pass: |
def bp_yield
yield
end
prelude: |
def bp_yield
yield
end
def bp_pass &b
bp_yield &b
end
def bp_pass &b
bp_yield &b
end
benchmark:
vm1_blockparam_pass: 'bp_pass{}
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_pass{}
end
loop_count: 1
'
loop_count: 30000000
17 changes: 7 additions & 10 deletions benchmark/vm1_blockparam_yield.yml
@@ -1,12 +1,9 @@
prelude: |
def bp_yield &b
yield
end
benchmark:
vm1_blockparam_yield: |
def bp_yield &b
yield
end
vm1_blockparam_yield: 'bp_yield{}
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_yield{}
end
loop_count: 1
'
loop_count: 30000000
15 changes: 6 additions & 9 deletions benchmark/vm1_const.yml
@@ -1,11 +1,8 @@
prelude: 'Const = 1
'
benchmark:
vm1_const: |
Const = 1
i = 0
while i<30_000_000 # while loop 1
i += 1
j = Const
k = Const
end
loop_count: 1
j = Const
k = Const
loop_count: 30000000
10 changes: 3 additions & 7 deletions benchmark/vm1_ensure.yml
@@ -1,13 +1,9 @@
benchmark:
vm1_ensure: |
i = 0
while i<30_000_000 # benchmark loop 1
i += 1
begin
begin
begin
ensure
end
ensure
end
ensure
end
loop_count: 1
loop_count: 30000000
14 changes: 6 additions & 8 deletions benchmark/vm1_float_simple.yml
@@ -1,10 +1,8 @@
prelude: |
f = 0.0
benchmark:
vm1_float_simple: |
i = 0.0; f = 0.0
while i<30_000_000
i += 1
f += 0.1; f -= 0.1
f += 0.1; f -= 0.1
f += 0.1; f -= 0.1
end
loop_count: 1
f += 0.1; f -= 0.1
f += 0.1; f -= 0.1
f += 0.1; f -= 0.1
loop_count: 30000000
18 changes: 7 additions & 11 deletions benchmark/vm1_gc_short_lived.yml
@@ -1,13 +1,9 @@
benchmark:
vm1_gc_short_lived: |
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end
loop_count: 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
loop_count: 30000000
48 changes: 22 additions & 26 deletions benchmark/vm1_gc_short_with_complex_long.yml
@@ -1,29 +1,25 @@
benchmark:
vm1_gc_short_with_complex_long: |
def nested_hash h, n
if n == 0
''
else
10.times{
h[Object.new] = nested_hash(h, n-1)
}
end
prelude: |
def nested_hash h, n
if n == 0
''
else
10.times{
h[Object.new] = nested_hash(h, n-1)
}
end
end
long_lived = Hash.new
nested_hash long_lived, 6
GC.start
GC.start
long_lived = Hash.new
nested_hash long_lived, 6
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end
loop_count: 1
GC.start
GC.start
benchmark:
vm1_gc_short_with_complex_long: |
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
loop_count: 30000000
25 changes: 11 additions & 14 deletions benchmark/vm1_gc_short_with_long.yml
@@ -1,16 +1,13 @@
prelude: |
long_lived = Array.new(1_000_000){|i| "#{i}"}
GC.start
GC.start
benchmark:
vm1_gc_short_with_long: |
long_lived = Array.new(1_000_000){|i| "#{i}"}
GC.start
GC.start
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end
loop_count: 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
loop_count: 30000000
26 changes: 10 additions & 16 deletions benchmark/vm1_gc_short_with_symbol.yml
@@ -1,19 +1,13 @@
prelude: |
# make many symbols
50_000.times{|i| sym = "sym#{i}".to_sym}
GC.start
GC.start
benchmark:
vm1_gc_short_with_symbol: |
50_000.times{|i| sym = "sym#{i}".to_sym}
GC.start
GC.start
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end
loop_count: 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
loop_count: 30000000
23 changes: 10 additions & 13 deletions benchmark/vm1_gc_wb_ary.yml
@@ -1,15 +1,12 @@
benchmark:
vm1_gc_wb_ary: |
short_lived_ary = []
prelude: |
short_lived_ary = []
if RUBY_VERSION >= "2.2.0"
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
end
if RUBY_VERSION >= "2.2.0"
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
end
i = 0
short_lived = ''
while i<30_000_000 # while loop 1
short_lived_ary[0] = short_lived # write barrier
i+=1
end
loop_count: 1
short_lived = ''
benchmark:
vm1_gc_wb_ary: |
short_lived_ary[0] = short_lived # write barrier
loop_count: 30000000

0 comments on commit 820ad9c

Please sign in to comment.