1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/benchs/headers_split_vs_match.rb

18 lines
359 B
Ruby
Raw Normal View History

2009-07-10 02:22:02 -04:00
require 'benchmark'
COUNT = 1000
data = "Content-Length: 100"
Benchmark.bmbm(25) do |bench|
bench.report('regex') do
COUNT.times do
header = data.match(/(.*):\s(.*)/)
"#{header[1]}: #{header[2]}"
end
end
bench.report('split') do
COUNT.times do
header = data.split(': ')
"#{header[0]}: #{header[1]}"
end
end
end