Why be satisfied with a 10-12% increase in speed when we can have an
order of magnitude? :)

sudo gem install rubyinline

--

require 'rubygems'
require 'inline'

module Kernel
  inline do |builder|
    builder.c "
      int roll(int n) {
        int sum = n;
        while (n-- > 0) {
          sum += (rand() % 6);
        }
        return sum;
      }
    "
  end
end

puts roll(3)