excon 0.64.0 → 0.65.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of excon might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/data/cacert.pem +108 -2
- data/excon.gemspec +7 -2
- data/lib/excon.rb +11 -11
- data/lib/excon/connection.rb +25 -25
- data/lib/excon/response.rb +1 -1
- data/lib/excon/version.rb +1 -1
- metadata +3 -101
- data/.document +0 -5
- data/.github/stale.yml +0 -17
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -17
- data/Gemfile +0 -19
- data/Rakefile +0 -41
- data/benchmarks/class_vs_lambda.rb +0 -50
- data/benchmarks/concat_vs_insert.rb +0 -21
- data/benchmarks/concat_vs_interpolate.rb +0 -22
- data/benchmarks/cr_lf.rb +0 -21
- data/benchmarks/downcase-eq-eq_vs_casecmp.rb +0 -169
- data/benchmarks/excon.rb +0 -69
- data/benchmarks/excon_vs.rb +0 -165
- data/benchmarks/for_vs_array_each.rb +0 -27
- data/benchmarks/for_vs_hash_each.rb +0 -27
- data/benchmarks/has_key-vs-lookup.rb +0 -177
- data/benchmarks/headers_case_sensitivity.rb +0 -83
- data/benchmarks/headers_split_vs_match.rb +0 -34
- data/benchmarks/implicit_block-vs-explicit_block.rb +0 -98
- data/benchmarks/merging.rb +0 -21
- data/benchmarks/single_vs_double_quotes.rb +0 -21
- data/benchmarks/string_ranged_index.rb +0 -87
- data/benchmarks/strip_newline.rb +0 -115
- data/benchmarks/vs_stdlib.rb +0 -82
- data/changelog.txt +0 -1113
- data/spec/excon/error_spec.rb +0 -139
- data/spec/excon/test/server_spec.rb +0 -28
- data/spec/excon_spec.rb +0 -7
- data/spec/helpers/file_path_helpers.rb +0 -22
- data/spec/helpers/warning_helpers.rb +0 -9
- data/spec/requests/basic_spec.rb +0 -40
- data/spec/requests/eof_requests_spec.rb +0 -36
- data/spec/requests/unix_socket_spec.rb +0 -38
- data/spec/requests/validation_spec.rb +0 -80
- data/spec/spec_helper.rb +0 -26
- data/spec/support/shared_contexts/test_server_context.rb +0 -83
- data/spec/support/shared_contexts/test_stub_context.rb +0 -11
- data/spec/support/shared_examples/shared_example_for_clients.rb +0 -220
- data/spec/support/shared_examples/shared_example_for_streaming_clients.rb +0 -20
- data/spec/support/shared_examples/shared_example_for_test_servers.rb +0 -16
- data/tests/authorization_header_tests.rb +0 -27
- data/tests/bad_tests.rb +0 -69
- data/tests/basic_tests.rb +0 -351
- data/tests/batch_requests.rb +0 -133
- data/tests/complete_responses.rb +0 -31
- data/tests/data/127.0.0.1.cert.crt +0 -17
- data/tests/data/127.0.0.1.cert.key +0 -28
- data/tests/data/excon.cert.crt +0 -17
- data/tests/data/excon.cert.key +0 -28
- data/tests/data/xs +0 -1
- data/tests/error_tests.rb +0 -145
- data/tests/header_tests.rb +0 -119
- data/tests/instrumentors/logging_instrumentor_tests.rb +0 -28
- data/tests/middleware_tests.rb +0 -27
- data/tests/middlewares/canned_response_tests.rb +0 -34
- data/tests/middlewares/capture_cookies_tests.rb +0 -34
- data/tests/middlewares/decompress_tests.rb +0 -157
- data/tests/middlewares/escape_path_tests.rb +0 -36
- data/tests/middlewares/idempotent_tests.rb +0 -245
- data/tests/middlewares/instrumentation_tests.rb +0 -315
- data/tests/middlewares/mock_tests.rb +0 -304
- data/tests/middlewares/redirect_follower_tests.rb +0 -112
- data/tests/pipeline_tests.rb +0 -40
- data/tests/proxy_tests.rb +0 -306
- data/tests/query_string_tests.rb +0 -87
- data/tests/rackups/basic.rb +0 -41
- data/tests/rackups/basic.ru +0 -3
- data/tests/rackups/basic_auth.ru +0 -14
- data/tests/rackups/deflater.ru +0 -4
- data/tests/rackups/proxy.ru +0 -18
- data/tests/rackups/query_string.ru +0 -13
- data/tests/rackups/redirecting.ru +0 -23
- data/tests/rackups/redirecting_with_cookie.ru +0 -40
- data/tests/rackups/request_headers.ru +0 -15
- data/tests/rackups/request_methods.ru +0 -21
- data/tests/rackups/response_header.ru +0 -18
- data/tests/rackups/ssl.ru +0 -16
- data/tests/rackups/ssl_mismatched_cn.ru +0 -15
- data/tests/rackups/ssl_verify_peer.ru +0 -16
- data/tests/rackups/streaming.ru +0 -30
- data/tests/rackups/thread_safety.ru +0 -17
- data/tests/rackups/timeout.ru +0 -14
- data/tests/rackups/webrick_patch.rb +0 -34
- data/tests/request_headers_tests.rb +0 -21
- data/tests/request_method_tests.rb +0 -47
- data/tests/request_tests.rb +0 -58
- data/tests/response_tests.rb +0 -197
- data/tests/servers/bad.rb +0 -25
- data/tests/servers/eof.rb +0 -17
- data/tests/servers/error.rb +0 -20
- data/tests/servers/good.rb +0 -342
- data/tests/servers/good_ipv4.rb +0 -8
- data/tests/servers/good_ipv6.rb +0 -8
- data/tests/test_helper.rb +0 -297
- data/tests/thread_safety_tests.rb +0 -39
- data/tests/timeout_tests.rb +0 -12
- data/tests/utils_tests.rb +0 -81
data/benchmarks/excon_vs.rb
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
|
-
require 'bundler'
|
3
|
-
|
4
|
-
Bundler.require(:default)
|
5
|
-
Bundler.require(:benchmark)
|
6
|
-
|
7
|
-
require 'sinatra/base'
|
8
|
-
|
9
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon')
|
10
|
-
|
11
|
-
module Excon
|
12
|
-
class Server < Sinatra::Base
|
13
|
-
|
14
|
-
def self.run
|
15
|
-
Rack::Handler::WEBrick.run(
|
16
|
-
Excon::Server.new,
|
17
|
-
:Port => 9292,
|
18
|
-
:AccessLog => [],
|
19
|
-
:Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR)
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
get '/data/:amount' do |amount|
|
24
|
-
'x' * amount.to_i
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def with_server(&block)
|
31
|
-
pid = Process.fork do
|
32
|
-
Excon::Server.run
|
33
|
-
end
|
34
|
-
loop do
|
35
|
-
sleep(1)
|
36
|
-
begin
|
37
|
-
Excon.get('http://localhost:9292/api/foo')
|
38
|
-
break
|
39
|
-
rescue
|
40
|
-
end
|
41
|
-
end
|
42
|
-
yield
|
43
|
-
ensure
|
44
|
-
Process.kill(9, pid)
|
45
|
-
end
|
46
|
-
|
47
|
-
require 'em-http-request'
|
48
|
-
require 'httparty'
|
49
|
-
require 'net/http'
|
50
|
-
require 'open-uri'
|
51
|
-
require 'rest_client'
|
52
|
-
require 'tach'
|
53
|
-
require 'typhoeus'
|
54
|
-
|
55
|
-
size = 10_000
|
56
|
-
path = '/data/' << size.to_s
|
57
|
-
url = 'http://localhost:9292' << path
|
58
|
-
|
59
|
-
times = 1_000
|
60
|
-
|
61
|
-
with_server do
|
62
|
-
|
63
|
-
Tach.meter(times) do
|
64
|
-
|
65
|
-
tach('curb (persistent)') do |n|
|
66
|
-
curb = Curl::Easy.new
|
67
|
-
|
68
|
-
n.times do
|
69
|
-
curb.url = url
|
70
|
-
curb.http_get
|
71
|
-
curb.body_str
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
tach('em-http-request') do |n|
|
76
|
-
EventMachine.run {
|
77
|
-
count = 0
|
78
|
-
|
79
|
-
n.times do
|
80
|
-
http = EventMachine::HttpRequest.new(url).get
|
81
|
-
|
82
|
-
http.callback {
|
83
|
-
http.response
|
84
|
-
count += 1
|
85
|
-
EM.stop if count == n
|
86
|
-
}
|
87
|
-
|
88
|
-
http.errback {
|
89
|
-
http.response
|
90
|
-
count += 1
|
91
|
-
EM.stop if count == n
|
92
|
-
}
|
93
|
-
end
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
tach('Excon') do
|
98
|
-
Excon.get(url).body
|
99
|
-
end
|
100
|
-
|
101
|
-
excon = Excon.new(url)
|
102
|
-
tach('Excon (persistent)') do
|
103
|
-
excon.request(:method => 'get').body
|
104
|
-
end
|
105
|
-
|
106
|
-
tach('HTTParty') do
|
107
|
-
HTTParty.get(url).body
|
108
|
-
end
|
109
|
-
|
110
|
-
tach('Net::HTTP') do
|
111
|
-
# Net::HTTP.get('localhost', path, 9292)
|
112
|
-
Net::HTTP.start('localhost', 9292) {|http| http.get(path).body }
|
113
|
-
end
|
114
|
-
|
115
|
-
Net::HTTP.start('localhost', 9292) do |http|
|
116
|
-
tach('Net::HTTP (persistent)') do
|
117
|
-
http.get(path).body
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
tach('open-uri') do
|
122
|
-
open(url).read
|
123
|
-
end
|
124
|
-
|
125
|
-
tach('RestClient') do
|
126
|
-
RestClient.get(url)
|
127
|
-
end
|
128
|
-
|
129
|
-
streamly = StreamlyFFI::Connection.new
|
130
|
-
tach('StreamlyFFI (persistent)') do
|
131
|
-
streamly.get(url)
|
132
|
-
end
|
133
|
-
|
134
|
-
tach('Typhoeus') do
|
135
|
-
Typhoeus::Request.get(url).body
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# +--------------------------+----------+
|
142
|
-
# | tach | total |
|
143
|
-
# +--------------------------+----------+
|
144
|
-
# | Excon (persistent) | 1.529095 |
|
145
|
-
# +--------------------------+----------+
|
146
|
-
# | curb (persistent) | 1.740387 |
|
147
|
-
# +--------------------------+----------+
|
148
|
-
# | Typhoeus | 1.876236 |
|
149
|
-
# +--------------------------+----------+
|
150
|
-
# | Excon | 2.001858 |
|
151
|
-
# +--------------------------+----------+
|
152
|
-
# | StreamlyFFI (persistent) | 2.200701 |
|
153
|
-
# +--------------------------+----------+
|
154
|
-
# | Net::HTTP | 2.395704 |
|
155
|
-
# +--------------------------+----------+
|
156
|
-
# | Net::HTTP (persistent) | 2.418099 |
|
157
|
-
# +--------------------------+----------+
|
158
|
-
# | HTTParty | 2.659317 |
|
159
|
-
# +--------------------------+----------+
|
160
|
-
# | RestClient | 2.958159 |
|
161
|
-
# +--------------------------+----------+
|
162
|
-
# | open-uri | 2.987051 |
|
163
|
-
# +--------------------------+----------+
|
164
|
-
# | em-http-request | 4.123798 |
|
165
|
-
# +--------------------------+----------+
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
data = ["some", "var", "goes", "in", :here, 0]
|
5
|
-
Tach.meter(1_000_000) do
|
6
|
-
tach('for') do
|
7
|
-
for element in data
|
8
|
-
element == nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
tach('each') do
|
12
|
-
data.each do |element|
|
13
|
-
element == nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
|
19
|
-
#
|
20
|
-
# +------+----------+
|
21
|
-
# | tach | total |
|
22
|
-
# +------+----------+
|
23
|
-
# | for | 2.958672 |
|
24
|
-
# +------+----------+
|
25
|
-
# | each | 2.983550 |
|
26
|
-
# +------+----------+
|
27
|
-
#
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
data = {"some" => "var", "goes" => "in", :here => 0}
|
5
|
-
Tach.meter(1_000_000) do
|
6
|
-
tach('for') do
|
7
|
-
for key, values in data
|
8
|
-
key == values
|
9
|
-
end
|
10
|
-
end
|
11
|
-
tach('each') do
|
12
|
-
data.each do |key, values|
|
13
|
-
key == values
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
|
19
|
-
#
|
20
|
-
# +------+----------+
|
21
|
-
# | tach | total |
|
22
|
-
# +------+----------+
|
23
|
-
# | each | 2.748909 |
|
24
|
-
# +------+----------+
|
25
|
-
# | for | 2.949512 |
|
26
|
-
# +------+----------+
|
27
|
-
#
|
@@ -1,177 +0,0 @@
|
|
1
|
-
# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell
|
2
|
-
|
3
|
-
require 'benchmark'
|
4
|
-
|
5
|
-
iters = 1000000
|
6
|
-
hash = {
|
7
|
-
'some_key' => 'some_val',
|
8
|
-
'nil_key' => nil
|
9
|
-
}
|
10
|
-
|
11
|
-
puts 'Hash#has_key vs. Hash#[]'
|
12
|
-
Benchmark.bmbm do |x|
|
13
|
-
x.report('Hash#has_key') do
|
14
|
-
iters.times.each do
|
15
|
-
hash.has_key? 'some_key'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
x.report('Hash#has_key (if statement)') do
|
20
|
-
iters.times.each do
|
21
|
-
if hash.has_key?('other_key')
|
22
|
-
"hooray!"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
x.report('Hash#has_key (non-existant)') do
|
28
|
-
iters.times.each do
|
29
|
-
hash.has_key? 'other_key'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
x.report('Hash#[]') do
|
34
|
-
iters.times.each do
|
35
|
-
hash['some_key']
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
x.report('Hash#[] (if statement)') do
|
40
|
-
iters.times.each do
|
41
|
-
if hash['some_key']
|
42
|
-
"hooray!"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
x.report('Hash#[] (non-existant)') do
|
48
|
-
iters.times.each do
|
49
|
-
hash['other_key']
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
x.report('Hash#has_key (if statement) explicit nil check') do
|
54
|
-
iters.times.each do
|
55
|
-
if hash.has_key?('nil_key') && !hash['nil_key'].nil?
|
56
|
-
"hooray!"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
x.report('Hash#has_key (if statement) implicit nil check') do
|
63
|
-
iters.times.each do
|
64
|
-
if hash.has_key?('nil_key') && hash['nil_key']
|
65
|
-
"hooray!"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
x.report('Hash#[] (if statement with nil)') do
|
71
|
-
iters.times.each do
|
72
|
-
if hash['nil_key']
|
73
|
-
"hooray!"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
=begin
|
80
|
-
|
81
|
-
$ rvm exec bash -c 'echo $RUBY_VERSION && ruby has_key-vs-hash\[key\].rb'
|
82
|
-
|
83
|
-
jruby-1.5.6
|
84
|
-
Hash#has_key vs. Hash#[]
|
85
|
-
Rehearsal ---------------------------------------------------------------
|
86
|
-
Hash#has_key 0.410000 0.000000 0.410000 ( 0.341000)
|
87
|
-
Hash#has_key (if statement) 0.145000 0.000000 0.145000 ( 0.145000)
|
88
|
-
Hash#has_key (non-existant) 0.116000 0.000000 0.116000 ( 0.116000)
|
89
|
-
Hash#[] 0.189000 0.000000 0.189000 ( 0.189000)
|
90
|
-
Hash#[] (if statement) 0.176000 0.000000 0.176000 ( 0.176000)
|
91
|
-
Hash#[] (non-existant) 0.302000 0.000000 0.302000 ( 0.302000)
|
92
|
-
------------------------------------------------------ total: 1.338000sec
|
93
|
-
|
94
|
-
user system total real
|
95
|
-
Hash#has_key 0.128000 0.000000 0.128000 ( 0.128000)
|
96
|
-
Hash#has_key (if statement) 0.128000 0.000000 0.128000 ( 0.128000)
|
97
|
-
Hash#has_key (non-existant) 0.153000 0.000000 0.153000 ( 0.153000)
|
98
|
-
Hash#[] 0.206000 0.000000 0.206000 ( 0.206000)
|
99
|
-
Hash#[] (if statement) 0.182000 0.000000 0.182000 ( 0.182000)
|
100
|
-
Hash#[] (non-existant) 0.252000 0.000000 0.252000 ( 0.252000)
|
101
|
-
|
102
|
-
macruby-0.7.1
|
103
|
-
Hash#has_key vs. Hash#[]
|
104
|
-
Rehearsal ---------------------------------------------------------------
|
105
|
-
Hash#has_key 2.530000 0.050000 2.580000 ( 1.917643)
|
106
|
-
Hash#has_key (if statement) 2.590000 0.050000 2.640000 ( 1.935221)
|
107
|
-
Hash#has_key (non-existant) 2.580000 0.050000 2.630000 ( 1.964230)
|
108
|
-
Hash#[] 2.240000 0.040000 2.280000 ( 1.640999)
|
109
|
-
Hash#[] (if statement) 3.620000 0.070000 3.690000 ( 2.530248)
|
110
|
-
Hash#[] (non-existant) 2.060000 0.040000 2.100000 ( 1.473487)
|
111
|
-
----------------------------------------------------- total: 15.920000sec
|
112
|
-
|
113
|
-
user system total real
|
114
|
-
Hash#has_key 2.230000 0.030000 2.260000 ( 1.661843)
|
115
|
-
Hash#has_key (if statement) 2.180000 0.040000 2.220000 ( 1.605644)
|
116
|
-
Hash#has_key (non-existant) 2.160000 0.040000 2.200000 ( 1.582561)
|
117
|
-
Hash#[] 2.160000 0.030000 2.190000 ( 1.581448)
|
118
|
-
Hash#[] (if statement) 3.440000 0.070000 3.510000 ( 2.393421)
|
119
|
-
Hash#[] (non-existant) 2.330000 0.040000 2.370000 ( 1.699338)
|
120
|
-
|
121
|
-
rbx-head
|
122
|
-
Hash#has_key vs. Hash#[]
|
123
|
-
Rehearsal ---------------------------------------------------------------
|
124
|
-
Hash#has_key 0.660584 0.004932 0.665516 ( 0.508601)
|
125
|
-
Hash#has_key (if statement) 0.261708 0.000532 0.262240 ( 0.263021)
|
126
|
-
Hash#has_key (non-existant) 0.265908 0.000827 0.266735 ( 0.259509)
|
127
|
-
Hash#[] 0.396607 0.001189 0.397796 ( 0.372997)
|
128
|
-
Hash#[] (if statement) 0.553003 0.001589 0.554592 ( 0.543859)
|
129
|
-
Hash#[] (non-existant) 0.323748 0.000884 0.324632 ( 0.319055)
|
130
|
-
------------------------------------------------------ total: 2.471511sec
|
131
|
-
|
132
|
-
user system total real
|
133
|
-
Hash#has_key 0.332239 0.000819 0.333058 ( 0.333809)
|
134
|
-
Hash#has_key (if statement) 0.284344 0.000521 0.284865 ( 0.285330)
|
135
|
-
Hash#has_key (non-existant) 0.339695 0.001301 0.340996 ( 0.324259)
|
136
|
-
Hash#[] 0.298555 0.000368 0.298923 ( 0.299557)
|
137
|
-
Hash#[] (if statement) 0.392755 0.000773 0.393528 ( 0.395473)
|
138
|
-
Hash#[] (non-existant) 0.277721 0.000464 0.278185 ( 0.278540)
|
139
|
-
|
140
|
-
ruby-1.8.7-p330
|
141
|
-
Hash#has_key vs. Hash#[]
|
142
|
-
Rehearsal ---------------------------------------------------------------
|
143
|
-
Hash#has_key 0.450000 0.000000 0.450000 ( 0.450143)
|
144
|
-
Hash#has_key (if statement) 0.440000 0.000000 0.440000 ( 0.448278)
|
145
|
-
Hash#has_key (non-existant) 0.420000 0.000000 0.420000 ( 0.416959)
|
146
|
-
Hash#[] 0.450000 0.000000 0.450000 ( 0.450727)
|
147
|
-
Hash#[] (if statement) 0.550000 0.000000 0.550000 ( 0.555043)
|
148
|
-
Hash#[] (non-existant) 0.530000 0.000000 0.530000 ( 0.527189)
|
149
|
-
------------------------------------------------------ total: 2.840000sec
|
150
|
-
|
151
|
-
user system total real
|
152
|
-
Hash#has_key 0.440000 0.000000 0.440000 ( 0.447746)
|
153
|
-
Hash#has_key (if statement) 0.450000 0.000000 0.450000 ( 0.450331)
|
154
|
-
Hash#has_key (non-existant) 0.420000 0.000000 0.420000 ( 0.419157)
|
155
|
-
Hash#[] 0.450000 0.000000 0.450000 ( 0.454438)
|
156
|
-
Hash#[] (if statement) 0.570000 0.000000 0.570000 ( 0.563948)
|
157
|
-
Hash#[] (non-existant) 0.520000 0.000000 0.520000 ( 0.527866)
|
158
|
-
|
159
|
-
ruby-1.9.2-p136
|
160
|
-
Hash#has_key vs. Hash#[]
|
161
|
-
Rehearsal ---------------------------------------------------------------
|
162
|
-
Hash#has_key 0.690000 0.000000 0.690000 ( 0.691657)
|
163
|
-
Hash#has_key (if statement) 0.630000 0.000000 0.630000 ( 0.638418)
|
164
|
-
Hash#has_key (non-existant) 0.640000 0.000000 0.640000 ( 0.637510)
|
165
|
-
Hash#[] 0.580000 0.000000 0.580000 ( 0.584500)
|
166
|
-
Hash#[] (if statement) 0.840000 0.010000 0.850000 ( 0.837541)
|
167
|
-
Hash#[] (non-existant) 0.810000 0.000000 0.810000 ( 0.811598)
|
168
|
-
------------------------------------------------------ total: 4.200000sec
|
169
|
-
|
170
|
-
user system total real
|
171
|
-
Hash#has_key 0.690000 0.000000 0.690000 ( 0.694192)
|
172
|
-
Hash#has_key (if statement) 0.640000 0.000000 0.640000 ( 0.641729)
|
173
|
-
Hash#has_key (non-existant) 0.630000 0.000000 0.630000 ( 0.634470)
|
174
|
-
Hash#[] 0.580000 0.000000 0.580000 ( 0.587844)
|
175
|
-
Hash#[] (if statement) 0.830000 0.000000 0.830000 ( 0.832323)
|
176
|
-
Hash#[] (non-existant) 0.790000 0.010000 0.800000 ( 0.791689)
|
177
|
-
=end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'stringio'
|
3
|
-
require 'tach'
|
4
|
-
|
5
|
-
def all_match_socket
|
6
|
-
io = StringIO.new
|
7
|
-
io << "Connection: close\n"
|
8
|
-
io << "Content-Length: 000\n"
|
9
|
-
io << "Content-Type: text/html\n"
|
10
|
-
io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
11
|
-
io << "Server: xxx\n"
|
12
|
-
io << "Transfer-Encoding: chunked\n"
|
13
|
-
io << "\n\n"
|
14
|
-
io.rewind
|
15
|
-
io
|
16
|
-
end
|
17
|
-
|
18
|
-
Formatador.display_line('all_match')
|
19
|
-
Formatador.indent do
|
20
|
-
Tach.meter(10_000) do
|
21
|
-
tach('compare on read') do
|
22
|
-
socket, headers = all_match_socket, {}
|
23
|
-
until ((data = socket.readline).chop!).empty?
|
24
|
-
key, value = data.split(': ')
|
25
|
-
headers[key] = value
|
26
|
-
(key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
|
27
|
-
(key.casecmp('Connection') == 0) && (value.casecmp('close') == 0)
|
28
|
-
(key.casecmp('Content-Length') == 0)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
tach('original') do
|
33
|
-
socket, headers = all_match_socket, {}
|
34
|
-
until ((data = socket.readline).chop!).empty?
|
35
|
-
key, value = data.split(': ')
|
36
|
-
headers[key] = value
|
37
|
-
end
|
38
|
-
headers.has_key?('Transfer-Encoding') && headers['Transfer-Encoding'].casecmp('chunked') == 0
|
39
|
-
headers.has_key?('Connection') && headers['Connection'].casecmp('close') == 0
|
40
|
-
headers.has_key?('Content-Length')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def none_match_socket
|
46
|
-
io = StringIO.new
|
47
|
-
io << "Cache-Control: max-age=0\n"
|
48
|
-
io << "Content-Type: text/html\n"
|
49
|
-
io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
50
|
-
io << "Expires: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
51
|
-
io << "Last-Modified: Xxx, 00 Xxx 0000 00:00:00 GMT\n"
|
52
|
-
io << "Server: xxx\n"
|
53
|
-
io << "\n\n"
|
54
|
-
io.rewind
|
55
|
-
io
|
56
|
-
end
|
57
|
-
|
58
|
-
Formatador.display_line('none_match')
|
59
|
-
Formatador.indent do
|
60
|
-
Tach.meter(10_000) do
|
61
|
-
tach('compare on read') do
|
62
|
-
socket, headers = none_match_socket, {}
|
63
|
-
until ((data = socket.readline).chop!).empty?
|
64
|
-
key, value = data.split(': ')
|
65
|
-
headers[key] = value
|
66
|
-
(key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
|
67
|
-
(key.casecmp('Connection') == 0) && (value.casecmp('close') == 0)
|
68
|
-
(key.casecmp('Content-Length') == 0)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
tach('original') do
|
73
|
-
socket, headers = none_match_socket, {}
|
74
|
-
until ((data = socket.readline).chop!).empty?
|
75
|
-
key, value = data.split(': ')
|
76
|
-
headers[key] = value
|
77
|
-
end
|
78
|
-
headers.has_key?('Transfer-Encoding') && headers['Transfer-Encoding'].casecmp('chunked') == 0
|
79
|
-
headers.has_key?('Connection') && headers['Connection'].casecmp('close') == 0
|
80
|
-
headers.has_key?('Content-Length')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|