#
# bench.rb
#
#   Copyright (c) 1999,2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
#
#   This program is free software.
#   You can distribute/modify this program under the terms of
#   the GNU General Public License version 2 or later.
#
# usage:
#
#   str = 'test string'
#   benchmark( 'strdup', 10_0000 ) do
#     str = str.dup
#   end
#

def benchmark( label, times, &block )
  begtime = Time.times.utime
  times.times( &block )
  endtime = Time.times.utime
  puts "#{label}: #{endtime - begtime} sec"
end
