packages feed

text-0.11.1.0: tests/benchmarks/ruby/utils.rb

require 'benchmark'

def benchmark(&block)
  runs = 100
  total = 0

  runs.times do |i|
    result = Benchmark.measure(&block).total
    $stderr.puts "Run #{i}: #{result}"
    total += result
  end

  total / runs 
end

def with_utf8_file(filename)
  File.open(filename, 'r:utf-8') do |file|
    yield file.read
  end
end