mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* benchmark/driver.rb: fix to output some helpful messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87375866a6
commit
2fe11b75d6
3 changed files with 26 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Sep 27 16:01:53 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* benchmark/driver.rb: fix to output some helpful messages.
|
||||||
|
|
||||||
Thu Sep 27 15:44:51 2007 Koichi Sasada <ko1@atdot.net>
|
Thu Sep 27 15:44:51 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* benchmark/driver.rb: added.
|
* benchmark/driver.rb: added.
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
str = '*' * 1_000_000
|
|
||||||
|
|
||||||
1.times{
|
|
||||||
str.split('*').size
|
|
||||||
}
|
|
|
@ -38,7 +38,8 @@ class BenchmarkDriver
|
||||||
@results = []
|
@results = []
|
||||||
|
|
||||||
if @verbose
|
if @verbose
|
||||||
puts Time.now
|
@start_time = Time.now
|
||||||
|
puts @start_time
|
||||||
@execs.each_with_index{|(e, v), i|
|
@execs.each_with_index{|(e, v), i|
|
||||||
puts "target #{i}: #{v}"
|
puts "target #{i}: #{v}"
|
||||||
}
|
}
|
||||||
|
@ -46,17 +47,23 @@ class BenchmarkDriver
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_results
|
def show_results
|
||||||
|
puts
|
||||||
if @verbose
|
if @verbose
|
||||||
puts '-----------------------------------------------------------'
|
puts '-----------------------------------------------------------'
|
||||||
puts 'raw data:'
|
puts 'raw data:'
|
||||||
pp @results
|
pp @results
|
||||||
|
|
||||||
|
puts
|
||||||
|
puts "Elapesed time: #{Time.now - @start_time} (sec)"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts '-----------------------------------------------------------'
|
puts '-----------------------------------------------------------'
|
||||||
puts 'benchmark results:'
|
puts 'benchmark results:'
|
||||||
|
|
||||||
if @verbose and @repeat > 1
|
if @verbose and @repeat > 1
|
||||||
puts "minimum results in each #{@repeat} measurements."
|
puts "minimum results in each #{@repeat} measurements."
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
|
puts "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
|
||||||
@results.each{|v, result|
|
@results.each{|v, result|
|
||||||
rets = []
|
rets = []
|
||||||
|
@ -104,6 +111,7 @@ class BenchmarkDriver
|
||||||
load prepare_file if FileTest.exist?(prepare_file)
|
load prepare_file if FileTest.exist?(prepare_file)
|
||||||
|
|
||||||
if @verbose
|
if @verbose
|
||||||
|
puts
|
||||||
puts '-----------------------------------------------------------'
|
puts '-----------------------------------------------------------'
|
||||||
puts name
|
puts name
|
||||||
puts File.read(file)
|
puts File.read(file)
|
||||||
|
@ -113,8 +121,16 @@ class BenchmarkDriver
|
||||||
result = [name]
|
result = [name]
|
||||||
result << @execs.map{|(e, v)|
|
result << @execs.map{|(e, v)|
|
||||||
(0...@repeat).map{
|
(0...@repeat).map{
|
||||||
print "#{v}\t" if @verbose
|
if @verbose
|
||||||
|
print "#{v}\t"
|
||||||
STDOUT.flush
|
STDOUT.flush
|
||||||
|
end
|
||||||
|
|
||||||
|
if !@verbose || !STDOUT.tty?
|
||||||
|
STDERR.print '.'
|
||||||
|
STDERR.flush
|
||||||
|
end
|
||||||
|
|
||||||
m = measure e, file
|
m = measure e, file
|
||||||
puts "#{m}" if @verbose
|
puts "#{m}" if @verbose
|
||||||
m
|
m
|
||||||
|
@ -125,8 +141,10 @@ class BenchmarkDriver
|
||||||
end
|
end
|
||||||
|
|
||||||
def measure executable, file
|
def measure executable, file
|
||||||
|
|
||||||
|
cmd = "#{executable} #{file}"
|
||||||
m = Benchmark.measure{
|
m = Benchmark.measure{
|
||||||
`#{executable} #{file}`
|
`#{cmd}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if $? != 0
|
if $? != 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue