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
2009-07-09 23:22:02 -07:00

18 lines
No EOL
359 B
Ruby

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