Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 17 lines (16 sloc) 0.434 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'benchmark'

Benchmark.bmbm do |x|
  string = "mimas.rh.com.tr\t\t77.75.34.2"
  result = %w( mimas.rh.com.tr 77.75.34.2 )
  x.report("split & strip") do
    100_000.times do
      string.split("\s").map { |value| value.strip } == result || raise
    end
  end
  x.report("split with regexp") do
    100_000.times do
      string.split(/\s+/) == result || raise
    end
  end
end
Something went wrong with that request. Please try again.