excon 0.62.0 → 0.92.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +0 -1
- data/LICENSE.md +1 -1
- data/README.md +7 -6
- data/data/cacert.pem +1220 -1828
- data/excon.gemspec +19 -3
- data/lib/excon/connection.rb +216 -139
- data/lib/excon/constants.rb +38 -13
- data/lib/excon/error.rb +15 -0
- data/lib/excon/headers.rb +4 -3
- data/lib/excon/instrumentors/logging_instrumentor.rb +5 -16
- data/lib/excon/instrumentors/standard_instrumentor.rb +2 -9
- data/lib/excon/middlewares/base.rb +6 -0
- data/lib/excon/middlewares/capture_cookies.rb +1 -1
- data/lib/excon/middlewares/decompress.rb +11 -4
- data/lib/excon/middlewares/expects.rb +7 -1
- data/lib/excon/middlewares/idempotent.rb +20 -3
- data/lib/excon/middlewares/instrumentor.rb +8 -0
- data/lib/excon/middlewares/mock.rb +12 -3
- data/lib/excon/middlewares/redirect_follower.rb +25 -3
- data/lib/excon/middlewares/response_parser.rb +3 -0
- data/lib/excon/pretty_printer.rb +1 -8
- data/lib/excon/response.rb +12 -9
- data/lib/excon/socket.rb +59 -42
- data/lib/excon/ssl_socket.rb +37 -15
- data/lib/excon/test/plugin/server/exec.rb +5 -2
- data/lib/excon/test/plugin/server/puma.rb +4 -1
- data/lib/excon/test/plugin/server/unicorn.rb +5 -0
- data/lib/excon/test/plugin/server/webrick.rb +4 -1
- data/lib/excon/test/server.rb +1 -1
- data/lib/excon/unix_socket.rb +1 -0
- data/lib/excon/utils.rb +59 -5
- data/lib/excon/version.rb +1 -1
- data/lib/excon.rb +25 -17
- metadata +27 -98
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -29
- 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 -1083
- 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/requests/basic_spec.rb +0 -40
- data/spec/requests/eof_requests_spec.rb +0 -36
- data/spec/requests/unix_socket_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -24
- data/spec/support/shared_contexts/test_server_context.rb +0 -83
- data/spec/support/shared_examples/shared_example_for_clients.rb +0 -218
- 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 -29
- data/tests/bad_tests.rb +0 -47
- 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 -20
- data/tests/data/127.0.0.1.cert.key +0 -27
- data/tests/data/excon.cert.crt +0 -20
- data/tests/data/excon.cert.key +0 -27
- data/tests/data/xs +0 -1
- data/tests/error_tests.rb +0 -145
- data/tests/header_tests.rb +0 -119
- 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 -206
- 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 -59
- data/tests/response_tests.rb +0 -197
- data/tests/servers/bad.rb +0 -20
- data/tests/servers/eof.rb +0 -17
- data/tests/servers/error.rb +0 -20
- data/tests/servers/good.rb +0 -350
- data/tests/test_helper.rb +0 -306
- data/tests/thread_safety_tests.rb +0 -39
- data/tests/timeout_tests.rb +0 -12
- data/tests/utils_tests.rb +0 -81
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.92.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dpiddy (Dan Peterson)
|
8
8
|
- geemus (Wesley Beary)
|
9
9
|
- nextmat (Matt Sanders)
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -180,6 +180,20 @@ dependencies:
|
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: webrick
|
185
|
+
requirement: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
type: :development
|
191
|
+
prerelease: false
|
192
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
183
197
|
description: EXtended http(s) CONnections
|
184
198
|
email: geemus@gmail.com
|
185
199
|
executables: []
|
@@ -189,35 +203,10 @@ extra_rdoc_files:
|
|
189
203
|
- CONTRIBUTORS.md
|
190
204
|
- CONTRIBUTING.md
|
191
205
|
files:
|
192
|
-
- ".document"
|
193
|
-
- ".gitignore"
|
194
|
-
- ".rspec"
|
195
|
-
- ".travis.yml"
|
196
206
|
- CONTRIBUTING.md
|
197
207
|
- CONTRIBUTORS.md
|
198
|
-
- Gemfile
|
199
208
|
- LICENSE.md
|
200
209
|
- README.md
|
201
|
-
- Rakefile
|
202
|
-
- benchmarks/class_vs_lambda.rb
|
203
|
-
- benchmarks/concat_vs_insert.rb
|
204
|
-
- benchmarks/concat_vs_interpolate.rb
|
205
|
-
- benchmarks/cr_lf.rb
|
206
|
-
- benchmarks/downcase-eq-eq_vs_casecmp.rb
|
207
|
-
- benchmarks/excon.rb
|
208
|
-
- benchmarks/excon_vs.rb
|
209
|
-
- benchmarks/for_vs_array_each.rb
|
210
|
-
- benchmarks/for_vs_hash_each.rb
|
211
|
-
- benchmarks/has_key-vs-lookup.rb
|
212
|
-
- benchmarks/headers_case_sensitivity.rb
|
213
|
-
- benchmarks/headers_split_vs_match.rb
|
214
|
-
- benchmarks/implicit_block-vs-explicit_block.rb
|
215
|
-
- benchmarks/merging.rb
|
216
|
-
- benchmarks/single_vs_double_quotes.rb
|
217
|
-
- benchmarks/string_ranged_index.rb
|
218
|
-
- benchmarks/strip_newline.rb
|
219
|
-
- benchmarks/vs_stdlib.rb
|
220
|
-
- changelog.txt
|
221
210
|
- data/cacert.pem
|
222
211
|
- excon.gemspec
|
223
212
|
- lib/excon.rb
|
@@ -250,76 +239,17 @@ files:
|
|
250
239
|
- lib/excon/unix_socket.rb
|
251
240
|
- lib/excon/utils.rb
|
252
241
|
- lib/excon/version.rb
|
253
|
-
- spec/excon/error_spec.rb
|
254
|
-
- spec/excon/test/server_spec.rb
|
255
|
-
- spec/excon_spec.rb
|
256
|
-
- spec/helpers/file_path_helpers.rb
|
257
|
-
- spec/requests/basic_spec.rb
|
258
|
-
- spec/requests/eof_requests_spec.rb
|
259
|
-
- spec/requests/unix_socket_spec.rb
|
260
|
-
- spec/spec_helper.rb
|
261
|
-
- spec/support/shared_contexts/test_server_context.rb
|
262
|
-
- spec/support/shared_examples/shared_example_for_clients.rb
|
263
|
-
- spec/support/shared_examples/shared_example_for_streaming_clients.rb
|
264
|
-
- spec/support/shared_examples/shared_example_for_test_servers.rb
|
265
|
-
- tests/authorization_header_tests.rb
|
266
|
-
- tests/bad_tests.rb
|
267
|
-
- tests/basic_tests.rb
|
268
|
-
- tests/batch_requests.rb
|
269
|
-
- tests/complete_responses.rb
|
270
|
-
- tests/data/127.0.0.1.cert.crt
|
271
|
-
- tests/data/127.0.0.1.cert.key
|
272
|
-
- tests/data/excon.cert.crt
|
273
|
-
- tests/data/excon.cert.key
|
274
|
-
- tests/data/xs
|
275
|
-
- tests/error_tests.rb
|
276
|
-
- tests/header_tests.rb
|
277
|
-
- tests/middlewares/canned_response_tests.rb
|
278
|
-
- tests/middlewares/capture_cookies_tests.rb
|
279
|
-
- tests/middlewares/decompress_tests.rb
|
280
|
-
- tests/middlewares/escape_path_tests.rb
|
281
|
-
- tests/middlewares/idempotent_tests.rb
|
282
|
-
- tests/middlewares/instrumentation_tests.rb
|
283
|
-
- tests/middlewares/mock_tests.rb
|
284
|
-
- tests/middlewares/redirect_follower_tests.rb
|
285
|
-
- tests/pipeline_tests.rb
|
286
|
-
- tests/proxy_tests.rb
|
287
|
-
- tests/query_string_tests.rb
|
288
|
-
- tests/rackups/basic.rb
|
289
|
-
- tests/rackups/basic.ru
|
290
|
-
- tests/rackups/basic_auth.ru
|
291
|
-
- tests/rackups/deflater.ru
|
292
|
-
- tests/rackups/proxy.ru
|
293
|
-
- tests/rackups/query_string.ru
|
294
|
-
- tests/rackups/redirecting.ru
|
295
|
-
- tests/rackups/redirecting_with_cookie.ru
|
296
|
-
- tests/rackups/request_headers.ru
|
297
|
-
- tests/rackups/request_methods.ru
|
298
|
-
- tests/rackups/response_header.ru
|
299
|
-
- tests/rackups/ssl.ru
|
300
|
-
- tests/rackups/ssl_mismatched_cn.ru
|
301
|
-
- tests/rackups/ssl_verify_peer.ru
|
302
|
-
- tests/rackups/streaming.ru
|
303
|
-
- tests/rackups/thread_safety.ru
|
304
|
-
- tests/rackups/timeout.ru
|
305
|
-
- tests/rackups/webrick_patch.rb
|
306
|
-
- tests/request_headers_tests.rb
|
307
|
-
- tests/request_method_tests.rb
|
308
|
-
- tests/request_tests.rb
|
309
|
-
- tests/response_tests.rb
|
310
|
-
- tests/servers/bad.rb
|
311
|
-
- tests/servers/eof.rb
|
312
|
-
- tests/servers/error.rb
|
313
|
-
- tests/servers/good.rb
|
314
|
-
- tests/test_helper.rb
|
315
|
-
- tests/thread_safety_tests.rb
|
316
|
-
- tests/timeout_tests.rb
|
317
|
-
- tests/utils_tests.rb
|
318
242
|
homepage: https://github.com/excon/excon
|
319
243
|
licenses:
|
320
244
|
- MIT
|
321
|
-
metadata:
|
322
|
-
|
245
|
+
metadata:
|
246
|
+
homepage_uri: https://github.com/excon/excon
|
247
|
+
bug_tracker_uri: https://github.com/excon/excon/issues
|
248
|
+
changelog_uri: https://github.com/excon/excon/blob/master/changelog.txt
|
249
|
+
documentation_uri: https://github.com/excon/excon/blob/master/README.md
|
250
|
+
source_code_uri: https://github.com/excon/excon
|
251
|
+
wiki_uri: https://github.com/excon/excon/wiki
|
252
|
+
post_install_message:
|
323
253
|
rdoc_options:
|
324
254
|
- "--charset=UTF-8"
|
325
255
|
require_paths:
|
@@ -335,9 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
335
265
|
- !ruby/object:Gem::Version
|
336
266
|
version: '0'
|
337
267
|
requirements: []
|
338
|
-
|
339
|
-
|
340
|
-
signing_key:
|
268
|
+
rubygems_version: 3.3.5
|
269
|
+
signing_key:
|
341
270
|
specification_version: 4
|
342
271
|
summary: speed, persistence, http(s)
|
343
272
|
test_files: []
|
data/.document
DELETED
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
before_install:
|
2
|
-
- gem install bundler
|
3
|
-
language: ruby
|
4
|
-
matrix:
|
5
|
-
allow_failures:
|
6
|
-
- rvm: 1.8.7
|
7
|
-
- rvm: 1.9.2
|
8
|
-
- rvm: jruby
|
9
|
-
- rvm: rbx-3.2
|
10
|
-
- rvm: ree
|
11
|
-
fast_finish: true
|
12
|
-
rvm:
|
13
|
-
- 1.8.7
|
14
|
-
- 1.9.2
|
15
|
-
- 1.9.3
|
16
|
-
- 2.0
|
17
|
-
- 2.1
|
18
|
-
- 2.2
|
19
|
-
- 2.3
|
20
|
-
- 2.4
|
21
|
-
- 2.5
|
22
|
-
- jruby
|
23
|
-
- rbx-3.2
|
24
|
-
- ree
|
25
|
-
script:
|
26
|
-
- "bundle exec shindont"
|
27
|
-
- "bundle exec rake spec[progress]"
|
28
|
-
|
29
|
-
sudo: false
|
data/Gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'jruby-openssl', '~> 0.9', :platform => :jruby
|
6
|
-
gem 'unicorn', :platforms => [:mri, :rbx], :groups => [:development, :test]
|
7
|
-
gem 'rubysl', '~> 2.0', :platform => :rbx
|
8
|
-
gem 'rack', '~> 1.6'
|
9
|
-
|
10
|
-
# group :benchmark do
|
11
|
-
# gem 'em-http-request'
|
12
|
-
# gem 'httparty'
|
13
|
-
# gem 'rest-client'
|
14
|
-
# gem 'tach'
|
15
|
-
# gem 'typhoeus'
|
16
|
-
# gem 'sinatra'
|
17
|
-
# gem 'streamly_ffi'
|
18
|
-
# gem 'curb'
|
19
|
-
# end
|
data/Rakefile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'shindo/rake'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rdoc/task'
|
5
|
-
|
6
|
-
Shindo::Rake.new
|
7
|
-
|
8
|
-
RSpec::Core::RakeTask.new(:spec, :format) do |t, args|
|
9
|
-
format = args[:format] || 'doc'
|
10
|
-
t.rspec_opts = ["-c", "-f #{format}", "-r ./spec/spec_helper.rb"]
|
11
|
-
t.pattern = 'spec/**/*_spec.rb'
|
12
|
-
end
|
13
|
-
|
14
|
-
task :default => [:tests, :test]
|
15
|
-
task :test => :spec
|
16
|
-
|
17
|
-
desc "update bundled certs"
|
18
|
-
task :update_certs do
|
19
|
-
# update curl bundle for end-users
|
20
|
-
require File.join(File.dirname(__FILE__), 'lib', 'excon')
|
21
|
-
File.open(File.join(File.dirname(__FILE__), 'data', 'cacert.pem'), 'w') do |file|
|
22
|
-
data = Excon.get("https://curl.haxx.se/ca/cacert.pem").body
|
23
|
-
file.write(data)
|
24
|
-
end
|
25
|
-
|
26
|
-
# update self-signed certs for tests
|
27
|
-
sh "openssl req -subj '/CN=excon/O=excon' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout tests/data/excon.cert.key -out tests/data/excon.cert.crt"
|
28
|
-
sh "openssl req -subj '/CN=127.0.0.1/O=excon' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout tests/data/127.0.0.1.cert.key -out tests/data/127.0.0.1.cert.crt"
|
29
|
-
end
|
30
|
-
|
31
|
-
desc "Open an irb session preloaded with this library"
|
32
|
-
task :console do
|
33
|
-
sh "irb -rubygems -r ./lib/#{name}.rb"
|
34
|
-
end
|
35
|
-
|
36
|
-
desc "check ssl settings"
|
37
|
-
task :hows_my_ssl do
|
38
|
-
require File.join(File.dirname(__FILE__), 'lib', 'excon')
|
39
|
-
data = Excon.get("https://www.howsmyssl.com/a/check").body
|
40
|
-
puts data
|
41
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
class Concatenator
|
5
|
-
def initialize(string)
|
6
|
-
@string = string
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(data)
|
10
|
-
@string << data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
string = "0123456789ABCDEF"
|
15
|
-
|
16
|
-
Tach.meter(100_000) do
|
17
|
-
tach('class') do
|
18
|
-
s = ""
|
19
|
-
obj = Concatenator.new(s)
|
20
|
-
10.times { obj.call(string) }
|
21
|
-
end
|
22
|
-
|
23
|
-
tach('lambda') do
|
24
|
-
s = ""
|
25
|
-
obj = lambda {|data| s << data }
|
26
|
-
10.times { obj.call(string) }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
|
31
|
-
#
|
32
|
-
# +--------+----------+
|
33
|
-
# | tach | total |
|
34
|
-
# +--------+----------+
|
35
|
-
# | class | 1.450284 |
|
36
|
-
# +--------+----------+
|
37
|
-
# | lambda | 2.506496 |
|
38
|
-
# +--------+----------+
|
39
|
-
|
40
|
-
# ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
|
41
|
-
#
|
42
|
-
# +--------+----------+
|
43
|
-
# | tach | total |
|
44
|
-
# +--------+----------+
|
45
|
-
# | class | 1.373917 |
|
46
|
-
# +--------+----------+
|
47
|
-
# | lambda | 2.589384 |
|
48
|
-
# +--------+----------+
|
49
|
-
|
50
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
Tach.meter(1_000_000) do
|
5
|
-
tach('concat') do
|
6
|
-
path = 'path'
|
7
|
-
path = '/' << path
|
8
|
-
end
|
9
|
-
tach('insert') do
|
10
|
-
path = 'path'
|
11
|
-
path.insert(0, '/')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# +--------+----------+
|
16
|
-
# | tach | total |
|
17
|
-
# +--------+----------+
|
18
|
-
# | insert | 0.974036 |
|
19
|
-
# +--------+----------+
|
20
|
-
# | concat | 0.998904 |
|
21
|
-
# +--------+----------+
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
key = 'Content-Length'
|
5
|
-
value = '100'
|
6
|
-
Tach.meter(1_000) do
|
7
|
-
tach('concat') do
|
8
|
-
temp = ''
|
9
|
-
temp << key << ': ' << value << "\r\n"
|
10
|
-
end
|
11
|
-
tach('interpolate') do
|
12
|
-
"#{key}: #{value}\r\n"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# +-------------+----------+
|
17
|
-
# | tach | total |
|
18
|
-
# +-------------+----------+
|
19
|
-
# | interpolate | 0.000404 |
|
20
|
-
# +-------------+----------+
|
21
|
-
# | concat | 0.000564 |
|
22
|
-
# +-------------+----------+
|
data/benchmarks/cr_lf.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tach'
|
3
|
-
|
4
|
-
CR_LF = "\r\n"
|
5
|
-
|
6
|
-
Tach.meter(1_000_000) do
|
7
|
-
tach('constant') do
|
8
|
-
'' << CR_LF
|
9
|
-
end
|
10
|
-
tach('string') do
|
11
|
-
'' << "\r\n"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# +----------+----------+
|
16
|
-
# | tach | total |
|
17
|
-
# +----------+----------+
|
18
|
-
# | constant | 0.819885 |
|
19
|
-
# +----------+----------+
|
20
|
-
# | string | 0.893602 |
|
21
|
-
# +----------+----------+
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell
|
2
|
-
|
3
|
-
require 'benchmark'
|
4
|
-
|
5
|
-
iters = 1000000
|
6
|
-
|
7
|
-
comp = "hello"
|
8
|
-
hello = "HelLo"
|
9
|
-
|
10
|
-
puts 'String#downcase == vs. String#casecmp'
|
11
|
-
Benchmark.bmbm do |x|
|
12
|
-
x.report('String#downcase1') do
|
13
|
-
iters.times.each do
|
14
|
-
hello.downcase == comp
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
x.report('String#downcase2') do
|
19
|
-
iters.times.each do
|
20
|
-
"HelLo".downcase == "hello"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
x.report('String#downcase3') do
|
25
|
-
iters.times.each do
|
26
|
-
var = "HelLo"
|
27
|
-
var.downcase!
|
28
|
-
var == "hello"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
x.report('casecmp1') do
|
33
|
-
iters.times.each do
|
34
|
-
hello.casecmp(comp).zero?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
x.report('casecmp1-1') do
|
39
|
-
iters.times.each do
|
40
|
-
hello.casecmp(comp) == 0
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
x.report('casecmp2') do
|
45
|
-
iters.times.each do
|
46
|
-
"HelLo".casecmp(comp).zero?
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
x.report('casecmp2-1') do
|
51
|
-
iters.times.each do
|
52
|
-
"HelLo".casecmp(comp) == 0
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
=begin
|
58
|
-
rvm exec bash -c 'echo && echo $RUBY_VERSION && echo && ruby downcase-eq-eq_vs_casecmp.rb'
|
59
|
-
|
60
|
-
jruby-1.5.6
|
61
|
-
|
62
|
-
String#downcase == vs. String#casecmp
|
63
|
-
Rehearsal ----------------------------------------------------
|
64
|
-
String#downcase1 0.461000 0.000000 0.461000 ( 0.387000)
|
65
|
-
String#downcase2 0.269000 0.000000 0.269000 ( 0.269000)
|
66
|
-
String#downcase3 0.224000 0.000000 0.224000 ( 0.224000)
|
67
|
-
casecmp1 0.157000 0.000000 0.157000 ( 0.157000)
|
68
|
-
casecmp1-1 0.153000 0.000000 0.153000 ( 0.153000)
|
69
|
-
casecmp2 0.163000 0.000000 0.163000 ( 0.163000)
|
70
|
-
casecmp2-1 0.163000 0.000000 0.163000 ( 0.163000)
|
71
|
-
------------------------------------------- total: 1.590000sec
|
72
|
-
|
73
|
-
user system total real
|
74
|
-
String#downcase1 0.190000 0.000000 0.190000 ( 0.191000)
|
75
|
-
String#downcase2 0.225000 0.000000 0.225000 ( 0.225000)
|
76
|
-
String#downcase3 0.190000 0.000000 0.190000 ( 0.190000)
|
77
|
-
casecmp1 0.125000 0.000000 0.125000 ( 0.125000)
|
78
|
-
casecmp1-1 0.127000 0.000000 0.127000 ( 0.127000)
|
79
|
-
casecmp2 0.144000 0.000000 0.144000 ( 0.144000)
|
80
|
-
casecmp2-1 0.147000 0.000000 0.147000 ( 0.147000)
|
81
|
-
|
82
|
-
macruby-0.7.1
|
83
|
-
|
84
|
-
String#downcase == vs. String#casecmp
|
85
|
-
Rehearsal ----------------------------------------------------
|
86
|
-
String#downcase1 2.340000 0.040000 2.380000 ( 1.765141)
|
87
|
-
String#downcase2 5.510000 0.100000 5.610000 ( 3.893249)
|
88
|
-
String#downcase3 4.200000 0.080000 4.280000 ( 3.031621)
|
89
|
-
casecmp1 0.270000 0.000000 0.270000 ( 0.267613)
|
90
|
-
casecmp1-1 0.190000 0.000000 0.190000 ( 0.188848)
|
91
|
-
casecmp2 1.450000 0.020000 1.470000 ( 1.027956)
|
92
|
-
casecmp2-1 1.380000 0.030000 1.410000 ( 0.951474)
|
93
|
-
------------------------------------------ total: 15.610000sec
|
94
|
-
|
95
|
-
user system total real
|
96
|
-
String#downcase1 2.350000 0.040000 2.390000 ( 1.774292)
|
97
|
-
String#downcase2 5.890000 0.120000 6.010000 ( 4.214038)
|
98
|
-
String#downcase3 4.530000 0.090000 4.620000 ( 3.286059)
|
99
|
-
casecmp1 0.270000 0.000000 0.270000 ( 0.271119)
|
100
|
-
casecmp1-1 0.190000 0.000000 0.190000 ( 0.189462)
|
101
|
-
casecmp2 1.540000 0.030000 1.570000 ( 1.104751)
|
102
|
-
casecmp2-1 1.440000 0.030000 1.470000 ( 0.999689)
|
103
|
-
|
104
|
-
rbx-head
|
105
|
-
|
106
|
-
String#downcase == vs. String#casecmp
|
107
|
-
Rehearsal ----------------------------------------------------
|
108
|
-
String#downcase1 0.702746 0.005229 0.707975 ( 0.621969)
|
109
|
-
String#downcase2 0.701429 0.001617 0.703046 ( 0.691833)
|
110
|
-
String#downcase3 1.042835 0.002952 1.045787 ( 0.953992)
|
111
|
-
casecmp1 0.654571 0.002239 0.656810 ( 0.480158)
|
112
|
-
casecmp1-1 0.484706 0.001105 0.485811 ( 0.398601)
|
113
|
-
casecmp2 0.564140 0.001579 0.565719 ( 0.545332)
|
114
|
-
casecmp2-1 0.554889 0.001153 0.556042 ( 0.539569)
|
115
|
-
------------------------------------------- total: 4.721190sec
|
116
|
-
|
117
|
-
user system total real
|
118
|
-
String#downcase1 0.491199 0.001081 0.492280 ( 0.493727)
|
119
|
-
String#downcase2 0.631059 0.001018 0.632077 ( 0.629885)
|
120
|
-
String#downcase3 0.968867 0.002504 0.971371 ( 0.976734)
|
121
|
-
casecmp1 0.364496 0.000434 0.364930 ( 0.365262)
|
122
|
-
casecmp1-1 0.373140 0.000562 0.373702 ( 0.374136)
|
123
|
-
casecmp2 0.487644 0.001057 0.488701 ( 0.490302)
|
124
|
-
casecmp2-1 0.469868 0.001178 0.471046 ( 0.472220)
|
125
|
-
|
126
|
-
ruby-1.8.7-p330
|
127
|
-
|
128
|
-
String#downcase == vs. String#casecmp
|
129
|
-
Rehearsal ----------------------------------------------------
|
130
|
-
String#downcase1 0.780000 0.000000 0.780000 ( 0.783979)
|
131
|
-
String#downcase2 0.950000 0.000000 0.950000 ( 0.954109)
|
132
|
-
String#downcase3 0.960000 0.000000 0.960000 ( 0.960554)
|
133
|
-
casecmp1 0.440000 0.000000 0.440000 ( 0.442546)
|
134
|
-
casecmp1-1 0.490000 0.000000 0.490000 ( 0.487795)
|
135
|
-
casecmp2 0.530000 0.000000 0.530000 ( 0.535819)
|
136
|
-
casecmp2-1 0.570000 0.000000 0.570000 ( 0.574653)
|
137
|
-
------------------------------------------- total: 4.720000sec
|
138
|
-
|
139
|
-
user system total real
|
140
|
-
String#downcase1 0.780000 0.000000 0.780000 ( 0.780692)
|
141
|
-
String#downcase2 0.980000 0.010000 0.990000 ( 0.982925)
|
142
|
-
String#downcase3 0.960000 0.000000 0.960000 ( 0.961501)
|
143
|
-
casecmp1 0.440000 0.000000 0.440000 ( 0.444528)
|
144
|
-
casecmp1-1 0.490000 0.000000 0.490000 ( 0.487437)
|
145
|
-
casecmp2 0.540000 0.000000 0.540000 ( 0.537686)
|
146
|
-
casecmp2-1 0.570000 0.000000 0.570000 ( 0.574253)
|
147
|
-
|
148
|
-
ruby-1.9.2-p136
|
149
|
-
|
150
|
-
String#downcase == vs. String#casecmp
|
151
|
-
Rehearsal ----------------------------------------------------
|
152
|
-
String#downcase1 0.750000 0.000000 0.750000 ( 0.750523)
|
153
|
-
String#downcase2 1.190000 0.000000 1.190000 ( 1.193346)
|
154
|
-
String#downcase3 1.030000 0.010000 1.040000 ( 1.036435)
|
155
|
-
casecmp1 0.640000 0.000000 0.640000 ( 0.640327)
|
156
|
-
casecmp1-1 0.480000 0.000000 0.480000 ( 0.484709) # With all this crap running, some flukes pop out
|
157
|
-
casecmp2 0.820000 0.000000 0.820000 ( 0.822223)
|
158
|
-
casecmp2-1 0.660000 0.000000 0.660000 ( 0.664190)
|
159
|
-
------------------------------------------- total: 5.580000sec
|
160
|
-
|
161
|
-
user system total real
|
162
|
-
String#downcase1 0.760000 0.000000 0.760000 ( 0.759816)
|
163
|
-
String#downcase2 1.150000 0.010000 1.160000 ( 1.150792)
|
164
|
-
String#downcase3 1.000000 0.000000 1.000000 ( 1.005549)
|
165
|
-
casecmp1 0.650000 0.000000 0.650000 ( 0.644021)
|
166
|
-
casecmp1-1 0.490000 0.000000 0.490000 ( 0.494456)
|
167
|
-
casecmp2 0.820000 0.000000 0.820000 ( 0.817689)
|
168
|
-
casecmp2-1 0.680000 0.000000 0.680000 ( 0.685121)
|
169
|
-
=end
|
data/benchmarks/excon.rb
DELETED
@@ -1,69 +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 'tach'
|
48
|
-
|
49
|
-
size = 10_000
|
50
|
-
path = '/data/' << size.to_s
|
51
|
-
url = 'http://localhost:9292' << path
|
52
|
-
|
53
|
-
times = 1_000
|
54
|
-
|
55
|
-
with_server do
|
56
|
-
|
57
|
-
Tach.meter(times) do
|
58
|
-
|
59
|
-
tach('Excon') do
|
60
|
-
Excon.get(url).body
|
61
|
-
end
|
62
|
-
|
63
|
-
excon = Excon.new(url)
|
64
|
-
tach('Excon (persistent)') do
|
65
|
-
excon.request(:method => 'get').body
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|