Skip to content

Instantly share code, notes, and snippets.

@mje113
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mje113/988f065369dd5693dffb to your computer and use it in GitHub Desktop.
Save mje113/988f065369dd5693dffb to your computer and use it in GitHub Desktop.
require 'rack'
require 'rack/test'
require 'uri'
include Rack::Test::Methods
class App
def call(env)
[ '200', { 'Content-Type' => 'text/html' }, [ URI('http://example.com').to_s] ]
end
end
def app
App.new
end
100_000.times do
get '/'
end
$ jruby -v
jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-21 0b2ea13 Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]
$ jruby -Xcompile.invokedynamic=true --profile uri_bench.rb
Profiling enabled; ^C shutdown will now dump profile info
main profile results:
Total time: 37.04
total self children calls method
----------------------------------------------------------------
35.35 0.10 35.25 3 Fixnum#times
35.24 0.16 35.08 100000 Rack::Test::Methods.get
34.91 0.04 34.87 300000 BasicObject#__send__
34.87 0.21 34.66 100000 Rack::Test::Session#get
23.54 0.27 23.28 901242 Class#new
22.13 0.13 22.00 300000 URI.parse
22.00 0.40 21.60 300000 URI::RFC3986_Parser#parse
21.00 1.04 19.96 400000 URI::Generic#initialize
19.39 0.25 19.14 700000 URI::Generic#default_port
19.14 19.14 0.00 700000 URI::Generic.default_port
17.42 1.11 16.32 100000 Rack::Test::Session#env_for
17.21 0.19 17.03 100000 Rack::Test::Session#process_request
15.00 0.61 14.39 100000 Rack::MockSession#request
11.46 0.20 11.26 100000 App#call
10.85 0.08 10.77 100000 Kernel.URI
10.00 0.11 9.89 100000 URI::HTTP#initialize
3.66 1.44 2.22 100000 Rack::MockRequest.env_for
1.97 0.09 1.88 100000 Rack::MockRequest.parse_uri_rfc2396
1.92 0.14 1.78 100000 Rack::MockResponse#initialize
1.88 0.13 1.75 100000 URI::RFC2396_Parser#parse
1.78 0.40 1.38 100000 Rack::Response#initialize
1.31 1.29 0.01 300000 URI::RFC3986_Parser#split
1.13 0.02 1.11 186 Kernel.require
0.99 0.09 0.90 28 Kernel.load
0.98 0.14 0.84 200000 URI::Generic#host=
0.81 0.22 0.59 200000 URI::Generic#check_host
0.77 0.29 0.48 100000 URI::RFC2396_Parser#split
0.75 0.01 0.74 62 Kernel.require
0.60 0.38 0.23 200000 URI::Generic#to_s
0.56 0.54 0.01 500000 URI::Generic#query=
0.48 0.48 0.00 200059 Regexp#=~
0.47 0.47 0.00 200090 Regexp#===
0.46 0.25 0.21 100000 Rack::Response#write
0.45 0.09 0.36 100000 Rack::Utils::HeaderHash#merge
0.39 0.23 0.17 100000 Rack::Test::Session#default_env
0.39 0.01 0.38 459 Array#each
0.37 0.15 0.22 100000 Rack::Utils.parse_nested_query
0.35 0.22 0.13 200000 Rack::Utils::HeaderHash#[]
0.35 0.30 0.05 200000 Rack::Utils::HeaderHash#[]=
0.34 0.21 0.14 100000 Rack::Response#finish
0.33 0.12 0.21 100000 Rack::Utils::HeaderHash#merge!
0.31 0.20 0.11 400000 URI::Generic#set_userinfo
0.31 0.00 0.31 2 Gem.try_activate
0.30 0.00 0.29 2 Gem::Specification.find_inactive_by_path
0.27 0.11 0.15 100000 Rack::Utils::HeaderHash.new
0.26 0.12 0.14 600098 Kernel.initialize_dup
0.26 0.08 0.17 100000 Rack::Test::Session#retry_with_digest_auth?
0.25 0.16 0.08 200000 Rack::Test::Session#last_response
0.22 0.00 0.22 132 Array#map
0.21 0.18 0.03 100000 Rack::Test::Utils.build_nested_query
$ jruby --profile uri_bench.rb
Profiling enabled; ^C shutdown will now dump profile info
main profile results:
Total time: 21.17
total self children calls method
----------------------------------------------------------------
19.71 0.09 19.62 3 Fixnum#times
19.60 0.16 19.44 100000 Rack::Test::Methods.get
19.24 0.03 19.21 300000 BasicObject#__send__
19.21 0.17 19.04 100000 Rack::Test::Session#get
9.79 0.94 8.85 100000 Rack::Test::Session#env_for
9.16 0.20 8.96 100000 Rack::Test::Session#process_request
6.82 0.59 6.23 100000 Rack::MockSession#request
6.29 0.32 5.98 1101136 Class#new
4.54 0.13 4.41 300000 URI.parse
4.44 1.21 3.22 100000 Rack::MockRequest.env_for
4.41 0.36 4.05 300000 URI::RFC3986_Parser#parse
3.00 1.10 1.89 400000 URI::Generic#initialize
2.60 0.15 2.46 100000 Rack::MockResponse#initialize
2.47 0.11 2.36 100000 App#call
2.42 0.36 2.06 100000 Rack::Response#initialize
1.99 0.11 1.88 100000 Kernel.URI
1.96 0.07 1.89 100000 Rack::MockRequest.parse_uri_rfc2396
1.89 0.10 1.79 100000 URI::RFC2396_Parser#parse
1.70 0.57 1.13 300000 URI::RFC3986_Parser#split
1.17 0.11 1.06 500200 Array#each
1.07 0.74 0.33 500000 URI::Generic#query=
1.06 0.02 1.04 186 Kernel.require
1.04 0.08 0.96 28 Kernel.load
1.01 0.11 0.91 200000 URI::Generic#host=
0.90 0.09 0.81 100000 URI::HTTP#initialize
0.88 0.24 0.65 200000 URI::Generic#check_host
0.87 0.20 0.67 100000 Rack::Response#write
0.81 0.25 0.56 100000 URI::RFC2396_Parser#split
0.81 0.81 0.00 500000 Regexp#match
0.71 0.62 0.10 3401753 Hash#[]
0.66 0.34 0.32 500003 Hash#each
0.64 0.30 0.33 200000 URI::Generic#to_s
0.49 0.06 0.43 100000 Rack::Utils::HeaderHash#merge
0.48 0.06 0.42 200000 Kernel.!~
0.47 0.47 0.00 2502719 Hash#[]=
0.47 0.31 0.15 700000 URI::Generic#default_port
0.45 0.45 0.00 200090 Regexp#===
0.44 0.00 0.44 62 Kernel.require
0.44 0.15 0.29 100000 Rack::Utils.parse_nested_query
0.42 0.42 0.00 200059 Regexp#=~
0.42 0.20 0.22 200000 Rack::Utils::HeaderHash#[]=
0.39 0.19 0.20 200000 Rack::Utils::HeaderHash#[]
0.35 0.12 0.22 100000 Rack::Test::Session#default_env
0.34 0.05 0.28 100000 Rack::Utils::HeaderHash#merge!
0.33 0.28 0.05 200000 Rack::Utils.bytesize
0.33 0.33 0.00 2300000 MatchData#[]
0.31 0.15 0.16 600098 Kernel.initialize_dup
0.31 0.15 0.16 400000 Hash#merge
0.30 0.18 0.12 100000 Rack::Response#finish
0.27 0.19 0.08 400000 URI::Generic#set_userinfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment