mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
benchmark/vm1_*.yml: abstract away the while loop
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
This commit is contained in:
parent
9e62c93d0d
commit
820ad9cb1d
30 changed files with 242 additions and 336 deletions
|
@ -73,15 +73,13 @@ loop_count: 1
|
|||
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
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_attr_ivar: |
|
||||
prelude: |
|
||||
class C
|
||||
attr_reader :a, :b
|
||||
def initialize
|
||||
|
@ -8,10 +7,8 @@ benchmark:
|
|||
end
|
||||
end
|
||||
obj = C.new
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
benchmark:
|
||||
vm1_attr_ivar: |
|
||||
j = obj.a
|
||||
k = obj.b
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_attr_ivar_set: |
|
||||
prelude: |
|
||||
class C
|
||||
attr_accessor :a, :b
|
||||
def initialize
|
||||
|
@ -8,10 +7,8 @@ benchmark:
|
|||
end
|
||||
end
|
||||
obj = C.new
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
benchmark:
|
||||
vm1_attr_ivar_set: |
|
||||
obj.a = 1
|
||||
obj.b = 2
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
benchmark:
|
||||
vm1_block: |
|
||||
prelude: |
|
||||
def m
|
||||
yield
|
||||
end
|
||||
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
benchmark:
|
||||
vm1_block: |
|
||||
m{
|
||||
}
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
benchmark:
|
||||
vm1_blockparam: |
|
||||
prelude: |
|
||||
def m &b
|
||||
end
|
||||
benchmark:
|
||||
vm1_blockparam: 'm{}
|
||||
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
m{}
|
||||
end
|
||||
loop_count: 1
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
benchmark:
|
||||
vm1_blockparam_call: |
|
||||
prelude: |
|
||||
def m &b
|
||||
b.call
|
||||
end
|
||||
benchmark:
|
||||
vm1_blockparam_call: 'm{}
|
||||
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
m{}
|
||||
end
|
||||
loop_count: 1
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_blockparam_pass: |
|
||||
prelude: |
|
||||
def bp_yield
|
||||
yield
|
||||
end
|
||||
|
@ -7,10 +6,8 @@ benchmark:
|
|||
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
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
benchmark:
|
||||
vm1_blockparam_yield: |
|
||||
prelude: |
|
||||
def bp_yield &b
|
||||
yield
|
||||
end
|
||||
benchmark:
|
||||
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
|
||||
|
|
|
@ -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
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
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
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -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
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -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
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_gc_short_with_complex_long: |
|
||||
prelude: |
|
||||
def nested_hash h, n
|
||||
if n == 0
|
||||
''
|
||||
|
@ -15,15 +14,12 @@ benchmark:
|
|||
|
||||
GC.start
|
||||
GC.start
|
||||
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
benchmark:
|
||||
vm1_gc_short_with_complex_long: |
|
||||
a = '' # short-lived String
|
||||
b = ''
|
||||
c = ''
|
||||
d = ''
|
||||
e = ''
|
||||
f = ''
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
benchmark:
|
||||
vm1_gc_short_with_long: |
|
||||
prelude: |
|
||||
long_lived = Array.new(1_000_000){|i| "#{i}"}
|
||||
GC.start
|
||||
GC.start
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
benchmark:
|
||||
vm1_gc_short_with_long: |
|
||||
a = '' # short-lived String
|
||||
b = ''
|
||||
c = ''
|
||||
d = ''
|
||||
e = ''
|
||||
f = ''
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
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
|
||||
benchmark:
|
||||
vm1_gc_short_with_symbol: |
|
||||
a = '' # short-lived String
|
||||
b = ''
|
||||
c = ''
|
||||
d = ''
|
||||
e = ''
|
||||
f = ''
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
benchmark:
|
||||
vm1_gc_wb_ary: |
|
||||
prelude: |
|
||||
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
|
||||
benchmark:
|
||||
vm1_gc_wb_ary: |
|
||||
short_lived_ary[0] = short_lived # write barrier
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_gc_wb_ary_promoted: |
|
||||
prelude: |
|
||||
long_lived = []
|
||||
|
||||
if RUBY_VERSION > "2.2.0"
|
||||
|
@ -8,10 +7,9 @@ benchmark:
|
|||
GC.start
|
||||
end
|
||||
|
||||
i = 0
|
||||
short_lived = ''
|
||||
while i<30_000_000 # while loop 1
|
||||
|
||||
benchmark:
|
||||
vm1_gc_wb_ary_promoted: |
|
||||
long_lived[0] = short_lived # write barrier
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_gc_wb_obj: |
|
||||
prelude: |
|
||||
class C
|
||||
attr_accessor :foo
|
||||
end
|
||||
|
@ -9,10 +8,8 @@ benchmark:
|
|||
GC.start(full_mark: false, immediate_mark: true, immediate_sweep: true)
|
||||
end
|
||||
|
||||
i = 0
|
||||
short_lived = ''
|
||||
while i<30_000_000 # while loop 1
|
||||
benchmark:
|
||||
vm1_gc_wb_obj: |
|
||||
short_lived_obj.foo = short_lived # write barrier
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_gc_wb_obj_promoted: |
|
||||
prelude: |
|
||||
class C
|
||||
attr_accessor :foo
|
||||
end
|
||||
|
@ -11,10 +10,8 @@ benchmark:
|
|||
GC.start
|
||||
end
|
||||
|
||||
i = 0
|
||||
short_lived = ''
|
||||
while i<30_000_000 # while loop 1
|
||||
benchmark:
|
||||
vm1_gc_wb_obj_promoted: |
|
||||
long_lived.foo = short_lived # write barrier
|
||||
i+=1
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
prelude: "@a = 1\n"
|
||||
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
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
benchmark:
|
||||
vm1_ivar_set: |
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
@a = 1
|
||||
@b = 2
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
benchmark:
|
||||
vm1_length: |
|
||||
prelude: |
|
||||
a = 'abc'
|
||||
b = [1, 2, 3]
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
benchmark:
|
||||
vm1_length: |
|
||||
a.length
|
||||
b.length
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
benchmark:
|
||||
vm1_lvar_init: |
|
||||
prelude: |
|
||||
def m v
|
||||
unless v
|
||||
# unreachable code
|
||||
|
@ -10,11 +9,8 @@ benchmark:
|
|||
v41 = v42 = v43 = v44 = v45 = v46 = v47 = v48 = v49 = v50 = 1
|
||||
end
|
||||
end
|
||||
benchmark:
|
||||
vm1_lvar_init: 'm i
|
||||
|
||||
i = 0
|
||||
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
m i
|
||||
end
|
||||
loop_count: 1
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
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
|
||||
vm1_lvar_set: 'a = b = c = d = e = f = g = h = j = k = l = m = n = o = p = q = r
|
||||
= 1
|
||||
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
benchmark:
|
||||
vm1_neq: |
|
||||
i = 0
|
||||
prelude: |
|
||||
obj1 = Object.new
|
||||
obj2 = Object.new
|
||||
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
benchmark:
|
||||
vm1_neq: |
|
||||
obj1 != obj2
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
prelude: |
|
||||
obj = Object.new
|
||||
benchmark:
|
||||
vm1_not: |
|
||||
i = 0
|
||||
obj = Object.new
|
||||
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
!obj
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
benchmark:
|
||||
vm1_rescue: |
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
begin
|
||||
rescue
|
||||
end
|
||||
end
|
||||
loop_count: 1
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
benchmark:
|
||||
vm1_simplereturn: |
|
||||
prelude: |
|
||||
def m
|
||||
return 1
|
||||
end
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
m
|
||||
end
|
||||
loop_count: 1
|
||||
benchmark:
|
||||
vm1_simplereturn: 'm
|
||||
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
benchmark:
|
||||
vm1_swap: |
|
||||
prelude: |
|
||||
a = 1
|
||||
b = 2
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
i += 1
|
||||
a, b = b, a
|
||||
end
|
||||
loop_count: 1
|
||||
benchmark:
|
||||
vm1_swap: 'a, b = b, a
|
||||
|
||||
'
|
||||
loop_count: 30000000
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# while loop cost is not removed due to benchmark_driver.gem's limitation
|
||||
benchmark:
|
||||
vm1_yield: |
|
||||
def m
|
||||
i = 0
|
||||
while i<30_000_000 # while loop 1
|
||||
while i<30_000_000
|
||||
i += 1
|
||||
yield
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue