Skip to content

Commit

Permalink
* benchmark/driver.rb: fix to output some helpful messages.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Sep 27, 2007
1 parent 8737586 commit 2fe11b7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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>

* benchmark/driver.rb: added.
Expand Down
5 changes: 0 additions & 5 deletions benchmark/bmx_temp.rb
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
str = '*' * 1_000_000

1.times{
str.split('*').size
}
26 changes: 22 additions & 4 deletions benchmark/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,32 @@ def initialize execs, dir, opt = {}
@results = []

if @verbose
puts Time.now
@start_time = Time.now
puts @start_time
@execs.each_with_index{|(e, v), i|
puts "target #{i}: #{v}"
}
end
end

def show_results
puts
if @verbose
puts '-----------------------------------------------------------'
puts 'raw data:'
pp @results

puts
puts "Elapesed time: #{Time.now - @start_time} (sec)"
end

puts '-----------------------------------------------------------'
puts 'benchmark results:'

if @verbose and @repeat > 1
puts "minimum results in each #{@repeat} measurements."
end

puts "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
@results.each{|v, result|
rets = []
Expand Down Expand Up @@ -104,6 +111,7 @@ def measure_file file
load prepare_file if FileTest.exist?(prepare_file)

if @verbose
puts
puts '-----------------------------------------------------------'
puts name
puts File.read(file)
Expand All @@ -113,8 +121,16 @@ def measure_file file
result = [name]
result << @execs.map{|(e, v)|
(0...@repeat).map{
print "#{v}\t" if @verbose
STDOUT.flush
if @verbose
print "#{v}\t"
STDOUT.flush
end

if !@verbose || !STDOUT.tty?
STDERR.print '.'
STDERR.flush
end

m = measure e, file
puts "#{m}" if @verbose
m
Expand All @@ -125,8 +141,10 @@ def measure_file file
end

def measure executable, file

cmd = "#{executable} #{file}"
m = Benchmark.measure{
`#{executable} #{file}`
`#{cmd}`
}

if $? != 0
Expand Down

0 comments on commit 2fe11b7

Please sign in to comment.