1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

benchmark: convert bm_vm1_*.rb to vm1_*.yml

This YAML transformation is needed to support whileloop time substituion
by benchmark_driver.gem later.

This commmit changes no benchmark behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-07-08 15:12:24 +00:00
parent 62e9563838
commit 95a187e040
58 changed files with 402 additions and 322 deletions

View file

@ -1,14 +0,0 @@
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

View file

@ -1,14 +0,0 @@
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

View file

@ -1,10 +0,0 @@
def m
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{
}
end

View file

@ -1,9 +0,0 @@
def m &b
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end

View file

@ -1,9 +0,0 @@
def m &b
b.call
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end

View file

@ -1,13 +0,0 @@
def bp_yield
yield
end
def bp_pass &b
bp_yield &b
end
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_pass{}
end

View file

@ -1,9 +0,0 @@
def bp_yield &b
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_yield{}
end

View file

@ -1,8 +0,0 @@
Const = 1
i = 0
while i<30_000_000 # while loop 1
i += 1
j = Const
k = Const
end

View file

@ -1,11 +0,0 @@
i = 0
while i<30_000_000 # benchmark loop 1
i += 1
begin
begin
ensure
end
ensure
end
end

View file

@ -1,7 +0,0 @@
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

View file

@ -1,10 +0,0 @@
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end

View file

@ -1,27 +0,0 @@
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
i = 0
while i<30_000_000 # while loop 1
a = '' # short-lived String
b = ''
c = ''
d = ''
e = ''
f = ''
i+=1
end

View file

@ -1,13 +0,0 @@
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

View file

@ -1,15 +0,0 @@
# make many symbols
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

View file

@ -1,12 +0,0 @@
short_lived_ary = []
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

View file

@ -1,14 +0,0 @@
long_lived = []
if RUBY_VERSION > "2.2.0"
3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
elsif
GC.start
end
i = 0
short_lived = ''
while i<30_000_000 # while loop 1
long_lived[0] = short_lived # write barrier
i+=1
end

View file

@ -1,15 +0,0 @@
class C
attr_accessor :foo
end
short_lived_obj = C.new
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_obj.foo = short_lived # write barrier
i+=1
end

View file

@ -1,17 +0,0 @@
class C
attr_accessor :foo
end
long_lived = C.new
if RUBY_VERSION >= "2.2.0"
3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
elsif
GC.start
end
i = 0
short_lived = ''
while i<30_000_000 # while loop 1
long_lived.foo = short_lived # write barrier
i+=1
end

View file

@ -1,8 +0,0 @@
@a = 1
i = 0
while i<30_000_000 # while loop 1
i += 1
j = @a
k = @a
end

View file

@ -1,6 +0,0 @@
i = 0
while i<30_000_000 # while loop 1
i += 1
@a = 1
@b = 2
end

View file

@ -1,9 +0,0 @@
a = 'abc'
b = [1, 2, 3]
i = 0
while i<30_000_000 # while loop 1
i += 1
a.length
b.length
end

View file

@ -1,18 +0,0 @@
def m v
unless v
# unreachable code
v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = v10 =
v11 = v12 = v13 = v14 = v15 = v16 = v17 = v18 = v19 = v20 =
v21 = v22 = v23 = v24 = v25 = v26 = v27 = v28 = v29 = v30 =
v31 = v32 = v33 = v34 = v35 = v36 = v37 = v38 = v39 = v40 =
v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
end
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m i
end

View file

@ -1,5 +0,0 @@
i = 0
while i<30_000_000 # while loop 1
i += 1
a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r = 1
end

View file

@ -1,8 +0,0 @@
i = 0
obj1 = Object.new
obj2 = Object.new
while i<30_000_000 # while loop 1
i += 1
obj1 != obj2
end

View file

@ -1,7 +0,0 @@
i = 0
obj = Object.new
while i<30_000_000 # while loop 1
i += 1
!obj
end

View file

@ -1,7 +0,0 @@
i = 0
while i<30_000_000 # while loop 1
i += 1
begin
rescue
end
end

View file

@ -1,9 +0,0 @@
def m
return 1
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m
end

View file

@ -1,8 +0,0 @@
a = 1
b = 2
i = 0
while i<30_000_000 # while loop 1
i += 1
a, b = b, a
end

View file

@ -1,10 +0,0 @@
def m
i = 0
while i<30_000_000 # while loop 1
i += 1
yield
end
end
m{}

View file

@ -0,0 +1,17 @@
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

View file

@ -0,0 +1,17 @@
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

13
benchmark/vm1_block.yml Normal file
View file

@ -0,0 +1,13 @@
benchmark:
vm1_block: |
def m
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{
}
end
loop_count: 1

View file

@ -0,0 +1,11 @@
benchmark:
vm1_blockparam: |
def m &b
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end
loop_count: 1

View file

@ -0,0 +1,12 @@
benchmark:
vm1_blockparam_call: |
def m &b
b.call
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m{}
end
loop_count: 1

View file

@ -0,0 +1,16 @@
benchmark:
vm1_blockparam_pass: |
def bp_yield
yield
end
def bp_pass &b
bp_yield &b
end
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_pass{}
end
loop_count: 1

View file

@ -0,0 +1,12 @@
benchmark:
vm1_blockparam_yield: |
def bp_yield &b
yield
end
i = 0
while i<30_000_000 # while loop 1
i += 1
bp_yield{}
end
loop_count: 1

11
benchmark/vm1_const.yml Normal file
View file

@ -0,0 +1,11 @@
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

13
benchmark/vm1_ensure.yml Normal file
View file

@ -0,0 +1,13 @@
benchmark:
vm1_ensure: |
i = 0
while i<30_000_000 # benchmark loop 1
i += 1
begin
begin
ensure
end
ensure
end
end
loop_count: 1

View file

@ -0,0 +1,10 @@
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

View file

@ -0,0 +1,13 @@
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

View file

@ -0,0 +1,29 @@
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
end
long_lived = Hash.new
nested_hash long_lived, 6
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

View file

@ -0,0 +1,16 @@
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

View file

@ -0,0 +1,19 @@
prelude: |
# make many symbols
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

View file

@ -0,0 +1,15 @@
benchmark:
vm1_gc_wb_ary: |
short_lived_ary = []
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

View file

@ -0,0 +1,17 @@
benchmark:
vm1_gc_wb_ary_promoted: |
long_lived = []
if RUBY_VERSION > "2.2.0"
3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
elsif
GC.start
end
i = 0
short_lived = ''
while i<30_000_000 # while loop 1
long_lived[0] = short_lived # write barrier
i+=1
end
loop_count: 1

View file

@ -0,0 +1,18 @@
benchmark:
vm1_gc_wb_obj: |
class C
attr_accessor :foo
end
short_lived_obj = C.new
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_obj.foo = short_lived # write barrier
i+=1
end
loop_count: 1

View file

@ -0,0 +1,20 @@
benchmark:
vm1_gc_wb_obj_promoted: |
class C
attr_accessor :foo
end
long_lived = C.new
if RUBY_VERSION >= "2.2.0"
3.times{ GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true) }
elsif
GC.start
end
i = 0
short_lived = ''
while i<30_000_000 # while loop 1
long_lived.foo = short_lived # write barrier
i+=1
end
loop_count: 1

11
benchmark/vm1_ivar.yml Normal file
View file

@ -0,0 +1,11 @@
benchmark:
vm1_ivar: |
@a = 1
i = 0
while i<30_000_000 # while loop 1
i += 1
j = @a
k = @a
end
loop_count: 1

View file

@ -0,0 +1,9 @@
benchmark:
vm1_ivar_set: |
i = 0
while i<30_000_000 # while loop 1
i += 1
@a = 1
@b = 2
end
loop_count: 1

11
benchmark/vm1_length.yml Normal file
View file

@ -0,0 +1,11 @@
benchmark:
vm1_length: |
a = 'abc'
b = [1, 2, 3]
i = 0
while i<30_000_000 # while loop 1
i += 1
a.length
b.length
end
loop_count: 1

View file

@ -0,0 +1,20 @@
benchmark:
vm1_lvar_init: |
def m v
unless v
# unreachable code
v1 = v2 = v3 = v4 = v5 = v6 = v7 = v8 = v9 = v10 =
v11 = v12 = v13 = v14 = v15 = v16 = v17 = v18 = v19 = v20 =
v21 = v22 = v23 = v24 = v25 = v26 = v27 = v28 = v29 = v30 =
v31 = v32 = v33 = v34 = v35 = v36 = v37 = v38 = v39 = v40 =
v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
end
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m i
end
loop_count: 1

View file

@ -0,0 +1,8 @@
benchmark:
vm1_lvar_set: |
i = 0
while i<30_000_000 # while loop 1
i += 1
a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r = 1
end
loop_count: 1

11
benchmark/vm1_neq.yml Normal file
View file

@ -0,0 +1,11 @@
benchmark:
vm1_neq: |
i = 0
obj1 = Object.new
obj2 = Object.new
while i<30_000_000 # while loop 1
i += 1
obj1 != obj2
end
loop_count: 1

10
benchmark/vm1_not.yml Normal file
View file

@ -0,0 +1,10 @@
benchmark:
vm1_not: |
i = 0
obj = Object.new
while i<30_000_000 # while loop 1
i += 1
!obj
end
loop_count: 1

10
benchmark/vm1_rescue.yml Normal file
View file

@ -0,0 +1,10 @@
benchmark:
vm1_rescue: |
i = 0
while i<30_000_000 # while loop 1
i += 1
begin
rescue
end
end
loop_count: 1

View file

@ -0,0 +1,11 @@
benchmark:
vm1_simplereturn: |
def m
return 1
end
i = 0
while i<30_000_000 # while loop 1
i += 1
m
end
loop_count: 1

10
benchmark/vm1_swap.yml Normal file
View file

@ -0,0 +1,10 @@
benchmark:
vm1_swap: |
a = 1
b = 2
i = 0
while i<30_000_000 # while loop 1
i += 1
a, b = b, a
end
loop_count: 1

12
benchmark/vm1_yield.yml Normal file
View file

@ -0,0 +1,12 @@
benchmark:
vm1_yield: |
def m
i = 0
while i<30_000_000 # while loop 1
i += 1
yield
end
end
m{}
loop_count: 1