Sha256: 56f4c4be98758816c504d63119314e2b86a3e7c39f910fd593dc2bd188ad116d

Contents?: true

Size: 505 Bytes

Versions: 9

Compression:

Stored size: 505 Bytes

Contents

require_relative "../lib/nyara/nyara"
include Nyara
require "benchmark"

def cookie1 s
  res = ParamHash.new
  s.split(/[,;] */n).reverse_each do |seg|
    Ext.parse_url_encoded_seg res, seg, false
  end
end

def cookie2 s
  res = ParamHash.new
  Ext.parse_cookie res, s
end

history = CGI.escape '历史'
s = "pgv_pvi; pgv_si=; pgv_pvi=som; sid=1d6c75f0 ; PLHistory=<#{history}>;"

puts Benchmark.measure{ 1000.times{cookie1 s} }
puts Benchmark.measure{ 1000.times{cookie2 s} }
# cookie2 should be faster

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nyara-0.0.1.pre.9 tools/bench-cookie.rb
nyara-0.0.1.pre.8 tools/bench-cookie.rb
nyara-0.0.1.pre.6 tools/bench-cookie.rb
nyara-0.0.1.pre.5 tools/bench-cookie.rb
nyara-0.0.1.pre.4 tools/bench-cookie.rb
nyara-0.0.1.pre.3 tools/bench-cookie.rb
nyara-0.0.1.pre.2 tools/bench-cookie.rb
nyara-0.0.1.pre.1 tools/bench-cookie.rb
nyara-0.0.1.pre tools/bench-cookie.rb