summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 01:33:43 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 01:33:43 (GMT)
commitb6dbffcd89ab051d49dd9ea8dc84f446000c82cd (patch)
treef420f315efa504073877877a0067c9b0b7c3b30d /benchmark
parentdb6a84b9cff54347892c63585e628ce5b7c84167 (diff)
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
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/driver.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index 0a4a136..defe3c3 100644
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -29,6 +29,25 @@ class BenchmarkDriver
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
puts(*args)
@output and @output.puts(*args)
@@ -351,6 +370,9 @@ if __FILE__ == $0
o.on('--rawdata-output [FILE]', 'output rawdata'){|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|
opt[:format] = r
}
@@ -365,6 +387,14 @@ if __FILE__ == $0
parser.parse!(ARGV)
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