Sha256: 7ef0e910cdbef74f15e43898fb7fdb1ad189d9c603fd4031223d9e6f28379036

Contents?: true

Size: 1.27 KB

Versions: 41

Compression:

Stored size: 1.27 KB

Contents

# require 'benchmark'

# COUNT = 1_000_000
# data = "Content-Length: 100"
# Benchmark.bmbm(25) do |bench|
#   bench.report('regex') do
#     COUNT.times do
#       header = data.match(/(.*):\s(.*)/)
#     end
#   end
#   bench.report('split') do
#     COUNT.times do
#       header = data.split(': ')
#     end
#   end
# end

# Rehearsal ------------------------------------------------------------
# regex                      4.270000   0.010000   4.280000 (  4.294186)
# split                      3.870000   0.000000   3.870000 (  3.885645)
# --------------------------------------------------- total: 8.150000sec
# 
#                                user     system      total        real
# regex                      4.260000   0.010000   4.270000 (  4.284764)
# split                      3.860000   0.010000   3.870000 (  3.882795)

require 'rubygems'
require 'tach'

data = "Content-Length: 100"
Tach.meter(1_000_000) do
  tach('regex') do
    data.match(/(.*):\s(.*)/)
    header = [$1, $2]
  end
  tach('split') do
    header = data.split(': ')
  end
end

# +-------+----------+----------+
# | tach  | average  | total    |
# +-------+----------+----------+
# | regex | 4.680451 | 4.680451 |
# +-------+----------+----------+
# | split | 4.393218 | 4.393218 |
# +-------+----------+----------+

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
excon-0.6.2 benchmarks/headers_split_vs_match.rb
excon-0.6.1 benchmarks/headers_split_vs_match.rb
excon-0.6.0 benchmarks/headers_split_vs_match.rb
excon-0.5.8 benchmarks/headers_split_vs_match.rb
excon-0.5.7 benchmarks/headers_split_vs_match.rb
excon-0.5.6 benchmarks/headers_split_vs_match.rb
excon-0.5.5 benchmarks/headers_split_vs_match.rb
excon-0.5.4 benchmarks/headers_split_vs_match.rb
excon-0.5.3 benchmarks/headers_split_vs_match.rb
excon-0.5.2 benchmarks/headers_split_vs_match.rb
excon-0.5.1 benchmarks/headers_split_vs_match.rb
excon-0.5.0 benchmarks/headers_split_vs_match.rb
excon-0.4.0 benchmarks/headers_split_vs_match.rb
excon-0.3.8 benchmarks/headers_split_vs_match.rb
excon-0.3.7 benchmarks/headers_split_vs_match.rb
excon-0.3.6 benchmarks/headers_split_vs_match.rb
excon-0.3.5 benchmarks/headers_split_vs_match.rb
excon-0.3.4 benchmarks/headers_split_vs_match.rb
excon-0.3.3 benchmarks/headers_split_vs_match.rb
excon-0.3.2 benchmarks/headers_split_vs_match.rb