<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -13,13 +13,17 @@ module Benchmark
       times1 = []
       times2 = []
       
+      teardown1 = @options[:teardown1]
+      teardown2 = @options[:teardown2]
       (1..@options[ :iterations ]).each do |iteration|
         if @options[ :verbose ]
           $stdout.print &quot;.&quot;; $stdout.flush
         end
         
         times1 &lt;&lt; Benchmark.realtime { @block1.call( iteration ) }
+        teardown1.call if teardown1.respond_to?(:call)
         times2 &lt;&lt; Benchmark.realtime { block2.call( iteration ) }
+        teardown2.call if teardown2.respond_to?(:call)
       end
       
       r = RSRuby.instance</diff>
      <filename>lib/better-benchmark/better-benchmark.rb</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1,41 @@
+require 'rubygems'
+require 'test/unit'
+require 'lib/better-benchmark'
+
+class TestBetterBenchmark &lt; Test::Unit::TestCase
+  
+  def test_teardowns_are_invoked
+    teardown_check = 2
+    teardown1 = Proc.new {
+      teardown_check = 1
+    }
+    teardown2 = Proc.new {
+      teardown_check = 2
+    }
+    
+    result = Benchmark.compare_realtime(
+      :iterations =&gt; 10,
+      :verbose =&gt; true,
+      :teardown1 =&gt; teardown1,
+      :teardown2 =&gt; teardown2
+    ) { |iteration|
+      assert_equal 2, teardown_check 
+    }.with { |iteration|
+      assert_equal 1, teardown_check
+    }
+    assert_equal 2, teardown_check
+  end
+  
+  def test_absence_of_teardowns_does_not_cause_error
+    assert_nothing_raised {
+      result = Benchmark.compare_realtime(
+        :iterations =&gt; 10,
+        :verbose =&gt; true
+      ) { |iteration|
+        # nothing
+      }.with { |iteration|
+        # nothing
+      }
+    }
+  end
+end
\ No newline at end of file</diff>
      <filename>test/test_better-benchmark.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>277a2774ae154d67bf9acc4b566f7c65bb3dadad</id>
    </parent>
  </parents>
  <author>
    <name>John Trupiano</name>
    <email>john@john-trupianos-macbook-pro.local</email>
  </author>
  <url>http://github.com/jtrupiano/better-benchmark/commit/2bc4a9f29aa94cf1603031c1a588213cb8495cc5</url>
  <id>2bc4a9f29aa94cf1603031c1a588213cb8495cc5</id>
  <committed-date>2008-10-14T09:29:17-07:00</committed-date>
  <authored-date>2008-10-14T09:29:17-07:00</authored-date>
  <message>Added :teardown1 and :teardown2 as options to the ComparisonPartial options parameter.  These options take Proc's (or objects that respond to call()).  :teardown1 follows block1, and :teardown2 follows block2 on each iteration.  This is helpful if you need to clean up state or otherwise execute transactional code in your benchmark.</message>
  <tree>b70de1e0ba5d02da81dfe5219b9428209ee6e159</tree>
  <committer>
    <name>John Trupiano</name>
    <email>john@john-trupianos-macbook-pro.local</email>
  </committer>
</commit>
