It seems it is more expensive to call a C function in 1.9 than it used
to be in 1.8:

[pbrannan@zem tmp]$ ruby test.rb
                          user     system      total        real
Ruby method           7.170000   0.010000   7.180000 (  7.177720)
C function            3.950000   0.000000   3.950000 (  3.953411)
[pbrannan@zem tmp]$ ruby1.9 test.rb
                          user     system      total        real
Ruby method           8.570000   0.000000   8.570000 (  8.580137)
C function            8.580000   0.000000   8.580000 (  8.591668)

[pbrannan@zem tmp]$ cat foo.c
#include "ruby.h"

VALUE foo(VALUE self)
{
  return Qnil;
}

void Init_foo()
{
  rb_define_global_function("foo", foo, 0);
}

[pbrannan@zem tmp]$ cat test.rb
require 'foo'
require 'benchmark'

N = 10_000_000

def bar
  return nil
end

Benchmark.bm(20) { |x|
  x.report("Ruby method") {
    for i in 1..N do
      bar
    end
  }

  x.report("C function") {
    for i in 1..N do
      foo
    end
  }
}

Why is this?

Paul