Skip to content

Commit b6dbffc

Browse files
committed
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
1 parent db6a84b commit b6dbffc

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

benchmark/driver.rb

+31-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ def self.benchmark(opt)
2929
end
3030
end
3131

32+
def self.load(input, type, opt)
33+
attrs = [:executables, :results]
34+
case type
35+
when 'yaml'
36+
require 'yaml'
37+
h = YAML.load(input)
38+
when 'json'
39+
require 'json'
40+
h = JSON.load(input)
41+
else
42+
h = eval(input.read)
43+
end
44+
obj = allocate
45+
obj.instance_variable_set("@execs", h[:executables] || h["executables"])
46+
obj.instance_variable_set("@results", h[:results] || h["results"])
47+
obj.instance_variable_set("@opt", opt)
48+
obj
49+
end
50+
3251
def output *args
3352
puts(*args)
3453
@output and @output.puts(*args)
@@ -351,6 +370,9 @@ def measure executable, file
351370
o.on('--rawdata-output [FILE]', 'output rawdata'){|r|
352371
opt[:rawdata_output] = r
353372
}
373+
o.on('--load-rawdata=FILE', 'input rawdata'){|r|
374+
opt[:rawdata_input] = r
375+
}
354376
o.on('-f', "--format=FORMAT", "output format (#{formats.keys.join(",")})", formats.keys){|r|
355377
opt[:format] = r
356378
}
@@ -365,6 +387,14 @@ def measure executable, file
365387

366388
parser.parse!(ARGV)
367389
opt[:output] ||= "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}#{formats[opt[:format]]}"
368-
BenchmarkDriver.benchmark(opt)
390+
391+
if input = opt[:rawdata_input]
392+
b = open(input) {|f|
393+
BenchmarkDriver.load(f, File.extname(input)[1..-1], opt)
394+
}
395+
b.show_results
396+
else
397+
BenchmarkDriver.benchmark(opt)
398+
end
369399
end
370400

0 commit comments

Comments
 (0)