summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 01:33:39 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 01:33:39 (GMT)
commitdb6a84b9cff54347892c63585e628ce5b7c84167 (patch)
tree70e725f4aecfc54fcfc41113885e4158e066024e /benchmark
parent3e557a979ecc2c9a43ffa3bbdb8fc2a6c5cfca61 (diff)
driver.rb: rawdata format
* benchmark/driver.rb (show_results): dump the rawdata in some formats, yaml, json, and pretty_inspect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/driver.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index 07c5ad4..0a4a136 100644
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -77,7 +77,6 @@ class BenchmarkDriver
@exclude = opt[:exclude] || nil
@verbose = opt[:quiet] ? false : (opt[:verbose] || false)
@output = opt[:output] ? open(opt[:output], 'w') : nil
- @rawdata_output = opt[:rawdata_output] ? open(opt[:rawdata_output], 'w') : nil
@loop_wl1 = @loop_wl2 = nil
@ruby_arg = opt[:ruby_arg] || nil
@opt = opt
@@ -148,12 +147,27 @@ class BenchmarkDriver
message "Elapsed time: #{Time.now - @start_time} (sec)"
end
- if @rawdata_output
+ if rawdata_output = @opt[:rawdata_output]
h = {}
h[:cpuinfo] = File.read('/proc/cpuinfo') if File.exist?('/proc/cpuinfo')
h[:executables] = @execs
h[:results] = @results
- @rawdata_output.puts h.inspect
+ if (type = File.extname(rawdata_output)).empty?
+ type = rawdata_output
+ rawdata_output = @output.path.sub(/\.[^.\/]+\z/, '') << '.' << rawdata_output
+ end
+ case type
+ when 'yaml'
+ require 'yaml'
+ h = YAML.dump(h)
+ when 'json'
+ require 'json'
+ h = JSON.pretty_generate(h)
+ else
+ require 'pp'
+ h = h.pretty_inspect
+ end
+ open(rawdata_output, 'w') {|f| f.puts h}
end
output '-----------------------------------------------------------'