[前][次][番号順一覧][スレッド一覧]

ruby-changes:37788

From: nobu <ko1@a...>
Date: Fri, 6 Mar 2015 10:33:55 +0900 (JST)
Subject: [ruby-changes:37788] nobu:r49869 (trunk): driver.rb: load-rawdata

nobu	2015-03-06 10:33:43 +0900 (Fri, 06 Mar 2015)

  New Revision: 49869

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49869

  Log:
    driver.rb: load-rawdata
    
    * benchmark/driver.rb: add --load-rawdata option to load dumped
      rawdata and just output it without actual benchmark.

  Modified files:
    trunk/benchmark/driver.rb
Index: benchmark/driver.rb
===================================================================
--- benchmark/driver.rb	(revision 49868)
+++ benchmark/driver.rb	(revision 49869)
@@ -29,6 +29,25 @@ class BenchmarkDriver https://github.com/ruby/ruby/blob/trunk/benchmark/driver.rb#L29
     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 https://github.com/ruby/ruby/blob/trunk/benchmark/driver.rb#L370
     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 https://github.com/ruby/ruby/blob/trunk/benchmark/driver.rb#L387
 
   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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]