<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -19,9 +19,9 @@ Examples:
 
 The results are generated within the results/ folder (automatically created for you). Running rake bench:to_csv creates a CSV spreadsheet out of them. This is quite handy for comparing your results over time.
 
-The following example runs '/bin/ruby_special' as the VM, 3 iterations instead of the default (i.e., 5), 5 second timeout (per script) instead of the default 300s, and outputs all messages instead of swallowing them (the default):
+The following example runs demonstrates all possible options -- '/bin/ruby_special' as the VM, 3 iterations instead of the default (i.e., 5), 5 second timeout (per script) instead of the default 300s, and outputs all messages instead of swallowing them (the default).  METER_MEMORY defaults to yes, change it to anything else to disable it (it requires slightly extra processing).
 
-  rake VM=/bin/ruby_special ITERATIONS=3 TIMEOUT=5 VERBOSE=1
+  rake VM=/bin/ruby_special ITERATIONS=3 TIMEOUT=5 VERBOSE=1 METER_MEMORY=yes
 
 DIRECTORY STRUCTURE
 ===================</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -17,10 +17,11 @@ WEB_DIR         = RESULTS_DIR + &quot;/web&quot;
 
 ITERATIONS      = (ENV['ITERATIONS'] || 5).to_i
 TIMEOUT         = (ENV['TIMEOUT'] || 300).to_i
+METER_MEMORY    = ENV['METER_MEMORY'] || 'yes'
 VM              = ENV['VM'] || &quot;ruby&quot;
 
 def command(name)
-  &quot;ruby #{MONITOR} #{TIMEOUT} '#{VM}' #{RUNNER} #{name} #{ITERATIONS} #{report}&quot;
+  &quot;ruby #{MONITOR} #{TIMEOUT} '#{VM}' #{RUNNER} #{name} #{ITERATIONS} #{report} #{METER_MEMORY}&quot;
 end
 
 # Cache the name so it is only generated once during an invocation.</diff>
      <filename>rakelib/bench.rake</filename>
    </modified>
    <modified>
      <diff>@@ -13,16 +13,19 @@
 # Bench.run will run the blocktime the running of the block for the requested
 # number of iterations and then compute some statistics and append
 # a YAML-formatted report to the specified file.
-
 class Bench
   attr_accessor :parameter
-  attr_reader   :times, :sorted, :file, :name, :n, :report
+  attr_reader   :times, :memory_readings, :sorted, :file, :name, :n, :report, :meter_memory
 
-  def initialize(name, n, report)
+  def initialize(name, n, report, meter_memory)
+   
     @name   = name
     @file   = File.basename name
     @n      = n.to_i
     @report = report
+    @meter_memory = meter_memory == 'yes' # default is yes
+
+    print 'meter memory is', meter_memory, @meter_memory
 
     reset
     self.class.register self
@@ -42,6 +45,7 @@ class Bench
 
   def reset
     @times = []
+    @memory_readings = []
     @mean  = nil
   end
 
@@ -54,6 +58,24 @@ class Bench
 
         finish = Time.now
         times &lt;&lt; finish - start
+        if @meter_memory
+          begin
+          if RUBY_PLATFORM =~ /mingw|mswin/
+             # windows
+             require 'rubygems'
+             require 'ruby-wmi' # of course, this will tweak memory readings a little
+             # but at least it will be constant across comparisons on windows
+             memory_used =  WMI::Win32_Process.find(:first, :conditions =&gt; {:ProcessId =&gt; Process.pid}).WorkingSetSize
+          else
+            kb = `ps -o rss= -p #{Process.pid}`.to_i # in kilobytes 
+            memory_used = kb*1024
+          end
+          memory_readings &lt;&lt; memory_used
+          rescue Exception =&gt; e
+            memory_readings &lt;&lt; e
+          end
+        end
+        
       end
     end
   end
@@ -67,7 +89,7 @@ class Bench
 
       yield input
 
-      @sorted = times.sort
+      @sorted = times.sort # sorted is used internally for collecting stats
       write_report
     end
   end
@@ -106,9 +128,15 @@ class Bench
       f.puts &quot;standard_deviation: #{standard_deviation}&quot;
       f.puts &quot;times:&quot;
       times.each { |t| f.puts &quot;- #{t}&quot; }
+      if @meter_memory
+         print 'doing memory readings', memory_readings.inspect
+         f.puts &quot;memory_readings:&quot;
+         memory_readings.each{|m| f.puts &quot;- #{m}&quot; }
+      end
     end
   end
 
+  # written after the report, meaning none of the tests resulted in an Exception, and all of them finished
   def write_success
     File.open report, &quot;a&quot; do |f|
       f.puts &quot;---&quot;
@@ -159,7 +187,7 @@ begin
   bench = Bench.new(*ARGV)
   load bench.file
   bench.write_success
-  rescue Object =&gt; exc
+rescue Object =&gt; exc
   bench.write_error exc if bench
   exit 1
 end</diff>
      <filename>utils/bench.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,10 +10,10 @@ if RUBY_PLATFORM =~ /mingw|mswin/
   null = &quot;NUL&quot;
 end
 
-limit, vm, runner, name, iterations, report = ARGV
+limit, vm, runner, name, iterations, report, meter_memory = ARGV
 
 start = Time.now
-cmd = &quot;#{timeout} -t #{limit} #{vm} #{runner} #{name} #{iterations} #{report}&quot;
+cmd = &quot;#{timeout} -t #{limit} #{vm} #{runner} #{name} #{iterations} #{report} #{meter_memory}&quot;
 cmd += &quot; &gt;#{null}&quot; unless ENV['VERBOSE']
 system cmd
 finish = Time.now</diff>
      <filename>utils/monitor.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b2b7d5dd2f5c01d0fbb6e5ff9f5fd66fd955c189</id>
    </parent>
  </parents>
  <author>
    <name>rdp</name>
    <email>rogerpack2005@gmail.com</email>
  </author>
  <url>http://github.com/acangiano/ruby-benchmark-suite/commit/731720b47769b3780dad241d7f5e6b26e9cabcf2</url>
  <id>731720b47769b3780dad241d7f5e6b26e9cabcf2</id>
  <committed-date>2009-10-10T17:06:27-07:00</committed-date>
  <authored-date>2009-10-10T17:06:27-07:00</authored-date>
  <message>add in memory readings for windows--uses ruby-wmi gem</message>
  <tree>724ddce21f2b8f9da25980cac7da18adfd4e9339</tree>
  <committer>
    <name>rdp</name>
    <email>rogerpack2005@gmail.com</email>
  </committer>
</commit>
