<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ext/measure_gc_runs.h</filename>
    </added>
    <added>
      <filename>ext/measure_gc_time.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -27,6 +27,10 @@
 #                                              (requires a patched Ruby interpreter).
 #                                        memory - Tracks total memory size
 #                                              (requires a patched Ruby interpreter).
+#                                        gc_runs - Tracks number of garbage collection runs
+#                                              (requires a patched Ruby interpreter).
+#                                        gc_time - Tracks time spent doing garbage collection
+#                                              (requires a patched Ruby interpreter).
 #         --replace-progname           Replace $0 when loading the .rb files.
 #         --specialized-instruction    Turn on specialized instruction.
 #     -h, --help                       Show help message
@@ -89,12 +93,15 @@ opts = OptionParser.new do |opts|
   end
     
   opts.on('--mode=measure_mode',
-      [:process, :wall, :cpu, :allocations],
+      [:process, :wall, :cpu, :allocations, :memory, :gc_runs, :gc_time],
       'Select what ruby-prof should measure:',
       '  process - Process time (default).',
       '  wall - Wall time.',
       '  cpu - CPU time (Pentium and PowerPCs only).',
-      '  allocations - Object allocations (requires patched Ruby interpreter).') do |measure_mode|
+      '  allocations - Object allocations (requires patched Ruby interpreter).',
+      '  memory - Allocated memory in KB (requires patched Ruby interpreter).',
+      '  gc_runs - Number of garbage collections (requires patched Ruby interpreter).',
+      '  gc_time - Time spent in garbage collection (requires patched Ruby interpreter).') do |measure_mode|
       
       case measure_mode
       when :process
@@ -107,6 +114,10 @@ opts = OptionParser.new do |opts|
         options.measure_mode = RubyProf::ALLOCATIONS
       when :memory
         options.measure_mode = RubyProf::MEMORY
+      when :gc_runs
+        options.measure_mode = RubyProf::GC_RUNS
+      when :gc_time
+        options.measure_mode = RubyProf::GC_TIME
       end
   end
         </diff>
      <filename>bin/ruby-prof</filename>
    </modified>
    <modified>
      <diff>@@ -16,9 +16,19 @@ else
 end
 
 have_header(&quot;sys/times.h&quot;)
+
+# Stefan Kaes / Alexander Dymo GC patch
 have_func(&quot;rb_os_allocated_objects&quot;)
 have_func(&quot;rb_gc_allocated_size&quot;)
+have_func(&quot;rb_gc_collections&quot;)
+have_func(&quot;rb_gc_time&quot;)
+
+# Lloyd Hilaiel's heap info patch
+have_func(&quot;rb_heap_total_mem&quot;)
+have_func(&quot;rb_gc_heap_info&quot;)
+
+# Ruby 1.9 unexposed methods
 have_func(&quot;rb_gc_malloc_allocations&quot;)
 have_func(&quot;rb_gc_malloc_allocated_size&quot;)
-have_func(&quot;rb_heap_total_mem&quot;)
+
 create_makefile(&quot;ruby_prof&quot;)</diff>
      <filename>ext/extconf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -77,6 +77,8 @@ typedef unsigned long prof_measure_t;
 #include &quot;measure_cpu_time.h&quot;
 #include &quot;measure_allocations.h&quot;
 #include &quot;measure_memory.h&quot;
+#include &quot;measure_gc_runs.h&quot;
+#include &quot;measure_gc_time.h&quot;
 
 static prof_measure_t (*get_measurement)() = measure_process_time;
 static double (*convert_measurement)(prof_measure_t) = convert_process_time;
@@ -1376,7 +1378,9 @@ prof_result_threads(VALUE self)
    *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows
    *RubyProf::CPU_TIME - Measure time using the CPU clock counter.  This mode is only supported on Pentium or PowerPC platforms. 
    *RubyProf::ALLOCATIONS - Measure object allocations.  This requires a patched Ruby interpreter.
-   *RubyProf::MEMORY - Measure memory size.  This requires a patched Ruby interpreter.*/
+   *RubyProf::MEMORY - Measure memory size.  This requires a patched Ruby interpreter.
+   *RubyProf::GC_RUNS - Measure number of garbage collections.  This requires a patched Ruby interpreter.
+   *RubyProf::GC_TIME - Measure time spent doing garbage collection.  This requires a patched Ruby interpreter.*/
 static VALUE
 prof_get_measure_mode(VALUE self)
 {
@@ -1392,7 +1396,9 @@ prof_get_measure_mode(VALUE self)
    *RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and GetLocalTime on Windows
    *RubyProf::CPU_TIME - Measure time using the CPU clock counter.  This mode is only supported on Pentium or PowerPC platforms. 
    *RubyProf::ALLOCATIONS - Measure object allocations.  This requires a patched Ruby interpreter.
-   *RubyProf::MEMORY - Measure memory size.  This requires a patched Ruby interpreter.*/
+   *RubyProf::MEMORY - Measure memory size.  This requires a patched Ruby interpreter.
+   *RubyProf::GC_RUNS - Measure number of garbage collections.  This requires a patched Ruby interpreter.
+   *RubyProf::GC_TIME - Measure time spent doing garbage collection.  This requires a patched Ruby interpreter.*/
 static VALUE
 prof_set_measure_mode(VALUE self, VALUE val)
 {
@@ -1436,7 +1442,21 @@ prof_set_measure_mode(VALUE self, VALUE val)
         convert_measurement = convert_memory;
         break;
       #endif
-        
+
+      #if defined(MEASURE_GC_RUNS)
+      case MEASURE_GC_RUNS:
+        get_measurement = measure_gc_runs;
+        convert_measurement = convert_gc_runs;
+        break;
+      #endif
+
+      #if defined(MEASURE_GC_TIME)
+      case MEASURE_GC_TIME:
+        get_measurement = measure_gc_time;
+        convert_measurement = convert_gc_time;
+        break;
+      #endif
+
       default:
         rb_raise(rb_eArgError, &quot;invalid mode: %d&quot;, mode);
         break;
@@ -1642,7 +1662,21 @@ Init_ruby_prof()
     rb_define_const(mProf, &quot;MEMORY&quot;, INT2NUM(MEASURE_MEMORY));
     rb_define_singleton_method(mProf, &quot;measure_memory&quot;, prof_measure_memory, 0); /* in measure_memory.h */
     #endif
-    
+
+    #ifndef MEASURE_GC_RUNS
+    rb_define_const(mProf, &quot;GC_RUNS&quot;, Qnil);
+    #else
+    rb_define_const(mProf, &quot;GC_RUNS&quot;, INT2NUM(MEASURE_GC_RUNS));
+    rb_define_singleton_method(mProf, &quot;measure_gc_runs&quot;, prof_measure_gc_runs, 0); /* in measure_gc_runs.h */
+    #endif
+
+    #ifndef MEASURE_GC_TIME
+    rb_define_const(mProf, &quot;GC_TIME&quot;, Qnil);
+    #else
+    rb_define_const(mProf, &quot;GC_TIME&quot;, INT2NUM(MEASURE_GC_TIME));
+    rb_define_singleton_method(mProf, &quot;measure_gc_time&quot;, prof_measure_gc_time, 0); /* in measure_gc_time.h */
+    #endif
+
     cResult = rb_define_class_under(mProf, &quot;Result&quot;, rb_cObject);
     rb_undef_method(CLASS_OF(cMethodInfo), &quot;new&quot;);
     rb_define_method(cResult, &quot;threads&quot;, prof_result_threads, 0);</diff>
      <filename>ext/ruby_prof.c</filename>
    </modified>
    <modified>
      <diff>@@ -27,8 +27,16 @@ module RubyProf
         when RubyProf.const_defined?(:MEMORY) &amp;&amp; RubyProf::MEMORY
           @value_scale = 1
           @output &lt;&lt; 'memory'
+        when RubyProf.const_defined?(:GC_RUNS) &amp;&amp; RubyProf::GC_RUNS
+          @value_scale = 1
+          @output &lt;&lt; 'gc_runs'
+        when RubyProf.const_defined?(:GC_TIME) &amp;&amp; RubyProf::GC_TIME
+          @value_scale = 1000000
+          @output &lt;&lt; 'gc_time'
+        else
+          raise &quot;Unknown measure mode: #{RubyProf.measure_mode}&quot;
       end
-      @output &lt;&lt; &quot;\n\n&quot;  
+      @output &lt;&lt; &quot;\n\n&quot;
 
       print_threads
     end</diff>
      <filename>lib/ruby-prof/call_tree_printer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,7 @@ class MeasurementTest &lt; Test::Unit::TestCase
     assert_kind_of Float, t
 
     u = RubyProf.measure_process_time
-    assert u &gt;= t, [t, u].inspect
+    assert u &gt; t, [t, u].inspect
   end
 
   def test_wall_time
@@ -36,7 +36,7 @@ class MeasurementTest &lt; Test::Unit::TestCase
       assert_kind_of Float, t
 
       u = RubyProf.measure_cpu_time
-      assert u &gt;= t, [t, u].inspect
+      assert u &gt; t, [t, u].inspect
     end
   end
 
@@ -46,7 +46,7 @@ class MeasurementTest &lt; Test::Unit::TestCase
       assert_kind_of Integer, t
 
       u = RubyProf.measure_allocations
-      assert u &gt;= t, [t, u].inspect
+      assert u &gt; t, [t, u].inspect
     end
   end
 
@@ -59,4 +59,28 @@ class MeasurementTest &lt; Test::Unit::TestCase
       assert u &gt;= t, [t, u].inspect
     end
   end
+
+  if RubyProf::GC_RUNS
+    def test_gc_runs
+      t = RubyProf.measure_gc_runs
+      assert_kind_of Integer, t
+
+      GC.start
+
+      u = RubyProf.measure_gc_runs
+      assert u &gt; t, [t, u].inspect
+    end
+  end
+
+  if RubyProf::GC_TIME
+    def test_gc_time
+      t = RubyProf.measure_gc_time
+      assert_kind_of Integer, t
+
+      GC.start
+
+      u = RubyProf.measure_gc_time
+      assert u &gt; t, [t, u].inspect
+    end
+  end
 end</diff>
      <filename>test/measurement_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1d63d1ead905eb47801fa1f06b8b507ee52a7167</id>
    </parent>
  </parents>
  <author>
    <name>bitsweat</name>
    <email>bitsweat@5fb4a865-4516-0410-ae3b-a609ddf12040</email>
  </author>
  <url>http://github.com/jeremy/ruby-prof/commit/c63ac38f13b58ab999cec24cf29b178246f9b97e</url>
  <id>c63ac38f13b58ab999cec24cf29b178246f9b97e</id>
  <committed-date>2008-06-28T00:58:55-07:00</committed-date>
  <authored-date>2008-06-28T00:58:55-07:00</authored-date>
  <message>Add GC_RUNS and GC_TIME measure modes.

git-svn-id: http://ruby-prof.rubyforge.org/svn@267 5fb4a865-4516-0410-ae3b-a609ddf12040</message>
  <tree>33b2518b686ebc7efe8ad65b2005d0a74afd5265</tree>
  <committer>
    <name>bitsweat</name>
    <email>bitsweat@5fb4a865-4516-0410-ae3b-a609ddf12040</email>
  </committer>
</commit>
