mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
driver.rb: load-rawdata
* benchmark/driver.rb: add --load-rawdata option to load dumped rawdata and just output it without actual benchmark. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
db6a84b9cf
commit
b6dbffcd89
1 changed files with 31 additions and 1 deletions
|
@ -29,6 +29,25 @@ class BenchmarkDriver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.load(input, type, opt)
|
||||||
|
attrs = [:executables, :results]
|
||||||
|
case type
|
||||||
|
when 'yaml'
|
||||||
|
require 'yaml'
|
||||||
|
h = YAML.load(input)
|
||||||
|
when 'json'
|
||||||
|
require 'json'
|
||||||
|
h = JSON.load(input)
|
||||||
|
else
|
||||||
|
h = eval(input.read)
|
||||||
|
end
|
||||||
|
obj = allocate
|
||||||
|
obj.instance_variable_set("@execs", h[:executables] || h["executables"])
|
||||||
|
obj.instance_variable_set("@results", h[:results] || h["results"])
|
||||||
|
obj.instance_variable_set("@opt", opt)
|
||||||
|
obj
|
||||||
|
end
|
||||||
|
|
||||||
def output *args
|
def output *args
|
||||||
puts(*args)
|
puts(*args)
|
||||||
@output and @output.puts(*args)
|
@output and @output.puts(*args)
|
||||||
|
@ -351,6 +370,9 @@ if __FILE__ == $0
|
||||||
o.on('--rawdata-output [FILE]', 'output rawdata'){|r|
|
o.on('--rawdata-output [FILE]', 'output rawdata'){|r|
|
||||||
opt[:rawdata_output] = r
|
opt[:rawdata_output] = r
|
||||||
}
|
}
|
||||||
|
o.on('--load-rawdata=FILE', 'input rawdata'){|r|
|
||||||
|
opt[:rawdata_input] = r
|
||||||
|
}
|
||||||
o.on('-f', "--format=FORMAT", "output format (#{formats.keys.join(",")})", formats.keys){|r|
|
o.on('-f', "--format=FORMAT", "output format (#{formats.keys.join(",")})", formats.keys){|r|
|
||||||
opt[:format] = r
|
opt[:format] = r
|
||||||
}
|
}
|
||||||
|
@ -365,6 +387,14 @@ if __FILE__ == $0
|
||||||
|
|
||||||
parser.parse!(ARGV)
|
parser.parse!(ARGV)
|
||||||
opt[:output] ||= "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}#{formats[opt[:format]]}"
|
opt[:output] ||= "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}#{formats[opt[:format]]}"
|
||||||
BenchmarkDriver.benchmark(opt)
|
|
||||||
|
if input = opt[:rawdata_input]
|
||||||
|
b = open(input) {|f|
|
||||||
|
BenchmarkDriver.load(f, File.extname(input)[1..-1], opt)
|
||||||
|
}
|
||||||
|
b.show_results
|
||||||
|
else
|
||||||
|
BenchmarkDriver.benchmark(opt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue