<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>config.rb</filename>
    </added>
    <added>
      <filename>empty.rb</filename>
    </added>
    <added>
      <filename>loop.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,20 @@
 IronRuby-stats
 
+A script for capturing interesting statistics about IronRuby
+
 == Pre-requisites
 1. git clone git://github.com/ironruby/ironruby.git
 2. Set up IronRuby for building: http://wiki.github.com/ironruby/ironruby
 
-== Running
+== Configuration
+
+Update config.rb with the path to your IronRuby repository (from step 1 above).
+
+For example, if you ran the &quot;git clone&quot; command in c:/dev, then this would be
+your REPO value:
+
+REPO = 'c:/dev/ironruby'
 
-ruby stats.rb
+== Usage
 
+ruby stats.rb [--all] [--build] [--binary] [--repo] [--startup] [--throughput] [-h|--help]</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
-REPO = &quot;c:/dev/dlr&quot;
+load 'config.rb'
 RB = &quot;#{REPO}/Merlin/Main/Languages/Ruby&quot;
 BIN = &quot;#{REPO}/Merlin/Main/Bin/debug&quot;
+CD = File.expand_path(File.dirname(__FILE__))
 
 require 'fileutils'
 require 'mymath'
@@ -8,89 +9,162 @@ require 'benchmark'
 require 'pp'
 
 #
-# Stat gathering
+# Helpers
 #
+require 'net/http'
+require 'uri'
 
-def build
-  puts &quot;Building IronRuby&quot;
-  Benchmark.measure do
-    FileUtils.cd(RB) { system 'rake compile &gt; nul' }
+module Helpers
+  def fetch(uri_str, limit = 10)
+    raise ArgumentError, 'HTTP redirect too deep' if limit == 0
+
+    response = Net::HTTP.get_response(URI.parse(uri_str))
+    case response
+    when Net::HTTPSuccess     then response
+    when Net::HTTPRedirection then fetch(response['location'], limit - 1)
+    else
+      response.error!
+    end
   end
-end
 
-def size_of_binaries
-  build unless File.exists? BIN
-  Dir[&quot;#{BIN}/*.{exe,dll,config}&quot;].
-    delete_if { |f|    f =~ /ClassInitGenerator|Tests/ }.
-    inject({}){ |s, f| s[f] = File.size(f); s          }
-end
+  def get_ironruby_from_github
+    print &quot;Downloading IronRuby from GitHub ... &quot;
+    FileUtils.rm 'ironruby.zip' if File.exist?(&quot;ironruby.zip&quot;)
+    resp = fetch(&quot;http://github.com/ironruby/ironruby/zipball/master&quot;)
+    size = 0
+    open('ironruby.zip', 'wb') do |file|
+      size = file.write(resp.body)
+      yield 'ironruby.zip' if block_given?
+    end
+    FileUtils.rm 'ironruby.zip'
+    {:size =&gt; size, :filename =&gt; 'ironruby.zip'}
+  end
+
+  def total_binary_size(binaries)
+    binaries.inject(0){|x,(_,y)| x += y }
+  end
 
-def github_size
-  get_ironruby_from_github[:size]
+  def mb(bytes)
+    bytes./(1_000_000.0).round_to(2)
+  end
 end
 
 #
-# Helpers
+# Stat gathering
 #
-require 'net/http'
-require 'uri'
-
-def fetch(uri_str, limit = 10)
-  raise ArgumentError, 'HTTP redirect too deep' if limit == 0
 
-  response = Net::HTTP.get_response(URI.parse(uri_str))
-  case response
-  when Net::HTTPSuccess     then response
-  when Net::HTTPRedirection then fetch(response['location'], limit - 1)
-  else
-    response.error!
+module Stats
+  include Helpers
+  
+  def build
+    Benchmark.measure do
+      FileUtils.cd(RB) { system 'rake compile &gt; nul' }
+    end
   end
-end
 
-def get_ironruby_from_github
-  puts &quot;Getting IronRuby from GitHub&quot;
-  FileUtils.rm 'ironruby.zip' if File.exist?(&quot;ironruby.zip&quot;)
-  resp = fetch(&quot;http://github.com/ironruby/ironruby/zipball/master&quot;)
-  size = 0
-  open('ironruby.zip', 'wb') do |file|
-    size = file.write(resp.body)
-    yield 'ironruby.zip' if block_given?
+  def size_of_binaries
+    build unless File.exists? BIN
+    Dir[&quot;#{BIN}/*.{exe,dll,config}&quot;].
+      delete_if { |f|    f =~ /ClassInitGenerator|Tests/ }.
+      inject({}){ |s, f| s[f] = File.size(f); s          }
   end
-  {:size =&gt; size, :filename =&gt; 'ironruby.zip'}
-end
 
-def total_binary_size(binaries)
-  binaries.inject(0){|x,(_,y)| x += y }
-end
+  def github_size
+    get_ironruby_from_github[:size]
+  end
 
-def mb(bytes)
-  bytes./(1_000_000.0).round_to(2)
+  def startup_time
+    results = nil
+    FileUtils.cd(BIN) do
+      results = Benchmark.measure do
+        `ir #{CD}/empty.rb`
+      end
+    end
+    results
+  end
+  
+  def throughput
+    results = nil
+    FileUtils.cd(BIN) do
+      results = `ir #{CD}/loop.rb`
+    end
+    results.to_f
+  end
 end
 
 #
 # Reporting
 #
 
-def report(type)
-  send(&quot;report_#{type}&quot;)
+class Report
+  class &lt;&lt; self 
+    include Stats
+    include Helpers
+  
+    def run(type)
+      send(&quot;report_#{type}&quot;)
+    end
+  
+    def report_build
+      puts &quot;Build time: #{build.real.round_to(2)} seconds&quot;
+    end
+  
+    def report_size_of_binaries
+      puts &quot;Binary size: #{mb(total_binary_size(size_of_binaries))}MB&quot;
+    end
+  
+    def report_github_size
+      puts &quot;Github repo size: #{mb(github_size)} MB&quot;
+    end
+  
+    def report_startup
+      puts &quot;Startup time: #{startup_time.real.round_to(2)} seconds&quot;
+    end
+
+    def report_throughput
+      puts &quot;Throughput: (100000 iterations) #{throughput.round_to(2)} seconds&quot;
+    end
+
+    def report_all
+      methods.sort.each do |m|
+        if m =~ /report_(.*)/ &amp;&amp; $1 != 'all'
+          send(m)
+        end
+      end
+    end
+  end
+  
 end
 
-def report_build
-  puts &quot;Build time: #{build.real.round_to(2)} seconds&quot;
-end
+#
+# Run the report
+#
 
-def report_size_of_binaries
-  puts &quot;Binary size: #{mb(total_binary_size(size_of_binaries))}MB&quot;
+def help
+  &lt;&lt;-EOS
+usage:
+  ruby stats.rb [--all] [--build] [--binary] [--repo] [--startup] [--throughput] [-h|--help]
+EOS
 end
 
-def report_github_size
-  puts &quot;Github repo size: #{mb(github_size)} MB&quot;
+if ARGV.empty?
+  puts help
 end
 
-#
-# Run the report
-#
-
-report :build
-report :size_of_binaries
-report :github_size
\ No newline at end of file
+ARGV.each do |arg|
+  case arg
+  when /--help/, /-h/: 
+    puts help
+    exit
+  when /--all/      : Report.run :all
+  when /--build/    : Report.run :build
+  when /--binary/   : Report.run :size_of_binary
+  when /--repo/     : Report.run :github_size
+  when /--startup/  : Report.run :startup
+  when /--throughput/  : Report.run :throughput
+  else
+    puts &quot;Unknown argument '#{arg}'&quot;
+    puts help
+    exit
+  end
+end
\ No newline at end of file</diff>
      <filename>stats.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3791d785a8512b4f24401fd8bbb56f518fc85f16</id>
    </parent>
  </parents>
  <author>
    <name>Jimmy Schementi</name>
    <email>jschementi@gmail.com</email>
  </author>
  <url>http://github.com/jredville/ironruby-stats/commit/bbe8a8a6a160a2f120274c52dc066596b9b78b9a</url>
  <id>bbe8a8a6a160a2f120274c52dc066596b9b78b9a</id>
  <committed-date>2009-01-27T00:45:21-08:00</committed-date>
  <authored-date>2009-01-27T00:45:21-08:00</authored-date>
  <message>Refactoring, and adds startup/throughput</message>
  <tree>9d92fb4c52a97e4ea5947a57ba12da77628cb0e0</tree>
  <committer>
    <name>Jimmy Schementi</name>
    <email>jschementi@gmail.com</email>
  </committer>
</commit>
