Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 18 lines (16 sloc) 0.434 kB
c90fafb @weppos String & Regexp benchmarks.
authored
1 $:.unshift(File.dirname(__FILE__) + '/../lib')
2 require 'benchmark'
3
4 Benchmark.bmbm do |x|
5 string = "mimas.rh.com.tr\t\t77.75.34.2"
6 result = %w( mimas.rh.com.tr 77.75.34.2 )
7 x.report("split & strip") do
8 100_000.times do
9 string.split("\s").map { |value| value.strip } == result || raise
10 end
11 end
12 x.report("split with regexp") do
13 100_000.times do
14 string.split(/\s+/) == result || raise
15 end
16 end
17 end
Something went wrong with that request. Please try again.