From db6a84b9cff54347892c63585e628ce5b7c84167 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Mar 2015 01:33:39 +0000 Subject: 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 --- benchmark/driver.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'benchmark/driver.rb') diff --git a/benchmark/driver.rb b/benchmark/driver.rb index 07c5ad484a..0a4a13696d 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 '-----------------------------------------------------------' -- cgit v1.2.3