padrino-performance 0.12.5 → 0.12.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +11 -1
  3. data/test/bench_core.rb +186 -0
  4. data/test/mem_core.rb +122 -0
  5. metadata +10 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8320738d9403d962cb216173ee8a260298f4b3bf
4
- data.tar.gz: 4eae5c68a989c60c6ab008329b59a69fb8a40897
3
+ metadata.gz: 8aafd09bd30cc36d7c7a13f2f42b9028db035e3a
4
+ data.tar.gz: 1bc797f92cc9ab8bc85f876d1f3b070294f62bd6
5
5
  SHA512:
6
- metadata.gz: fe0786a52f693e930d0c96a812ef0fe2573fc787be47c6dc8c2e527c03764fa38e869559f736ed9d83afd86433917265f01b3d3917193e02dd22f35381197d36
7
- data.tar.gz: cca44c7791eaf283b306db6c484573d398c25ac8949a30744be9d141e8c5c2cc4669956bcaae28a13a1bc8d3037df5b7131691e0712e0c339a854ed6a7d74bad
6
+ metadata.gz: fbe8bc704027f28f24cf4c1d30ba6eefde98b8acde695106f2cbcb7ea58621bccbddc1406903e7def8c650887d9a1e22b09d665989bcbeab42fc4c3321a5c70f
7
+ data.tar.gz: 96d295a479b4cfce0d0e09573b4d8005fcec3b8ba0c6d61dda45a8f314526d230fea9c45bbddd1baae7d681adea595453f88c040e0128ff787e1c9cbed9d6ca8
data/Rakefile CHANGED
@@ -2,4 +2,14 @@
2
2
  RAKE_ROOT = __FILE__
3
3
 
4
4
  require 'rubygems'
5
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
5
+ require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
6
+
7
+ Rake::TestTask.new(:bench) do |test|
8
+ test.libs << 'test'
9
+ test.test_files = Dir['test/**/bench_*.rb']
10
+ end
11
+
12
+ Rake::TestTask.new(:mem) do |test|
13
+ test.libs << 'test'
14
+ test.test_files = Dir['test/**/mem_*.rb']
15
+ end
@@ -0,0 +1,186 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'padrino-core'
4
+
5
+ require 'minitest/autorun'
6
+ require 'minitest/benchmark'
7
+ require 'rack/test'
8
+
9
+ module MockBenchmark
10
+ include Rack::Test::Methods
11
+
12
+ module Settings
13
+ def bench_range
14
+ [20, 80, 320, 1280, 5120]
15
+ end
16
+
17
+ def run(*)
18
+ puts 'Running ' + self.name
19
+ super
20
+ end
21
+ end
22
+
23
+ def self.paths
24
+ @paths ||= (1..100).map{ rand(36**8).to_s(36) }
25
+ end
26
+
27
+ def self.included(base)
28
+ base.extend Settings
29
+ end
30
+
31
+ def result_code
32
+ ''
33
+ end
34
+
35
+ def app
36
+ @app
37
+ end
38
+
39
+ module BenchmarkRouting
40
+ def bench_calling_404
41
+ assert_performance_linear 0.99 do |n|
42
+ n.times do
43
+ get "/#{@paths.sample}_not_found"
44
+ end
45
+ end
46
+ assert_equal 404, last_response.status
47
+ end
48
+
49
+ def bench_calling_one_path
50
+ assert_performance_linear 0.99 do |n|
51
+ n.times do
52
+ get '/foo'
53
+ end
54
+ end
55
+ assert_equal 200, last_response.status
56
+ end
57
+
58
+ def bench_calling_sample
59
+ assert_performance_linear 0.99 do |n|
60
+ n.times do
61
+ get "/#{@paths.sample}"
62
+ end
63
+ end
64
+ assert_equal 200, last_response.status
65
+ end
66
+
67
+ def bench_calling_params
68
+ assert_performance_linear 0.99 do |n|
69
+ n.times do
70
+ get "/foo?foo=bar&zoo=#{@paths.sample}"
71
+ end
72
+ end
73
+ assert_equal 200, last_response.status
74
+ end
75
+
76
+ def bench_sample_and_params
77
+ assert_performance_linear 0.99 do |n|
78
+ n.times do
79
+ get "/#{@paths.sample}?foo=bar&zoo=#{@paths.sample}"
80
+ end
81
+ end
82
+ assert_equal 200, last_response.status
83
+ end
84
+ end
85
+ end
86
+
87
+ class Padrino::CoreBenchmark < Minitest::Benchmark
88
+ include MockBenchmark
89
+ include MockBenchmark::BenchmarkRouting
90
+
91
+ def setup
92
+ Padrino.clear!
93
+
94
+ @app = Sinatra.new Padrino::Application do
95
+ get("/foo") { "okey" }
96
+
97
+ MockBenchmark.paths.each do |p|
98
+ get("/#{p}") { p.to_s }
99
+ end
100
+ end
101
+
102
+ @paths = MockBenchmark.paths
103
+
104
+ get '/'
105
+ end
106
+ end
107
+
108
+ class SinatraBenchmark < Minitest::Benchmark
109
+ include MockBenchmark
110
+ include MockBenchmark::BenchmarkRouting
111
+
112
+ def setup
113
+ @app = Sinatra.new do
114
+ get("/foo") { "okey" }
115
+
116
+ MockBenchmark.paths.each do |p|
117
+ get("/#{p}") { p.to_s }
118
+ end
119
+ end
120
+
121
+ @paths = MockBenchmark.paths
122
+
123
+ get '/'
124
+ end
125
+ end
126
+
127
+ class Padrino::MounterBenchmark < Minitest::Benchmark
128
+ include MockBenchmark
129
+
130
+ class TestApp < Padrino::Application
131
+ get '/' do
132
+ 'OK'
133
+ end
134
+ end
135
+
136
+ def setup
137
+ Padrino.clear!
138
+
139
+ MockBenchmark.paths.each do |p|
140
+ Padrino.mount(TestApp).to("/#{p}")
141
+ end
142
+
143
+ @paths = MockBenchmark.paths
144
+ end
145
+
146
+ def bench_mounted_sample
147
+ request = Rack::MockRequest.new(Padrino.application)
148
+ response = nil
149
+ assert_performance_linear 0.99 do |n|
150
+ n.times do
151
+ response = request.get("/#{@paths.sample}")
152
+ end
153
+ end
154
+ assert_equal 200, response.status
155
+ end
156
+ end
157
+
158
+ class Padrino::HugeRouterBenchmark < Minitest::Benchmark
159
+ include MockBenchmark
160
+
161
+ def setup
162
+ @apps = {}
163
+ @pathss = {}
164
+ @requests = {}
165
+ self.class.bench_range.each do |n|
166
+ @pathss[n] = paths = (1..n/20).map{ rand(36**8).to_s(36) }
167
+ @apps[n] = Sinatra.new Padrino::Application do
168
+ paths.each do |p|
169
+ get("/#{p}") { p.to_s }
170
+ end
171
+ end
172
+ @requests[n] = Rack::MockRequest.new(@apps[n])
173
+ @requests[n].get('/')
174
+ end
175
+ end
176
+
177
+ def bench_calling_sample
178
+ response = nil
179
+ assert_performance_linear 0.99 do |n|
180
+ n.times do
181
+ response = @requests[n].get("/#{@pathss[n].sample}")
182
+ end
183
+ end
184
+ assert_equal 200, response.status
185
+ end
186
+ end
@@ -0,0 +1,122 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'padrino-core'
4
+
5
+ require 'minitest/autorun'
6
+ require 'minitest/benchmark'
7
+ require 'rack/test'
8
+ require 'memory_profiler'
9
+
10
+ module MockBenchmark
11
+ include Rack::Test::Methods
12
+
13
+ module Settings
14
+ def bench_range
15
+ [20, 80, 320, 1280]
16
+ end
17
+
18
+ def run(*)
19
+ puts 'Running ' + self.name
20
+ puts `pmap -x #{$$} | tail -1`
21
+ report = MemoryProfiler.report do
22
+ super
23
+ end
24
+ puts `pmap -x #{$$} | tail -1`
25
+ #puts `pmap -x #{$$}`
26
+ report.pretty_print
27
+ end
28
+ end
29
+
30
+ def self.paths
31
+ @paths ||= (1..100).map{ rand(36**8).to_s(36) }
32
+ end
33
+
34
+ def self.included(base)
35
+ base.extend Settings
36
+ end
37
+
38
+ def result_code
39
+ ''
40
+ end
41
+
42
+ def app
43
+ @app
44
+ end
45
+
46
+ module BenchmarkRouting
47
+ def bench_calling_404
48
+ assert_performance_linear 0.99 do |n|
49
+ n.times do
50
+ get "/#{@paths.sample}_not_found"
51
+ end
52
+ end
53
+ assert_equal 404, last_response.status
54
+ end
55
+
56
+ def bench_calling_one_path
57
+ assert_performance_linear 0.99 do |n|
58
+ n.times do
59
+ get '/foo'
60
+ end
61
+ end
62
+ assert_equal 200, last_response.status
63
+ end
64
+
65
+ def bench_calling_sample
66
+ assert_performance_linear 0.99 do |n|
67
+ n.times do
68
+ get "/#{@paths.sample}"
69
+ end
70
+ end
71
+ assert_equal 200, last_response.status
72
+ end
73
+
74
+ def bench_calling_params
75
+ assert_performance_linear 0.99 do |n|
76
+ n.times do
77
+ get "/foo?foo=bar&zoo=#{@paths.sample}"
78
+ end
79
+ end
80
+ assert_equal 200, last_response.status
81
+ end
82
+
83
+ def bench_sample_and_params
84
+ assert_performance_linear 0.99 do |n|
85
+ n.times do
86
+ get "/#{@paths.sample}?foo=bar&zoo=#{@paths.sample}"
87
+ end
88
+ end
89
+ assert_equal 200, last_response.status
90
+ end
91
+ end
92
+ end
93
+
94
+ class Padrino::HugeRouterBenchmark < Minitest::Benchmark
95
+ include MockBenchmark
96
+
97
+ def setup
98
+ @apps = {}
99
+ @pathss = {}
100
+ @requests = {}
101
+ self.class.bench_range.each do |n|
102
+ @pathss[n] = paths = (1..n/20).map{ rand(36**8).to_s(36) }
103
+ @apps[n] = Sinatra.new Padrino::Application do
104
+ paths.each do |p|
105
+ get("/#{p}") { p.to_s }
106
+ end
107
+ end
108
+ @requests[n] = Rack::MockRequest.new(@apps[n])
109
+ @requests[n].get('/')
110
+ end
111
+ end
112
+
113
+ def bench_calling_sample
114
+ response = nil
115
+ assert_performance_linear 0.99 do |n|
116
+ n.times do
117
+ response = @requests[n].get("/#{@pathss[n].sample}")
118
+ end
119
+ end
120
+ assert_equal 200, response.status
121
+ end
122
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2015-03-04 00:00:00.000000000 Z
17
+ date: 2016-05-09 00:00:00.000000000 Z
18
18
  dependencies: []
19
19
  description: A gem for finding performance problems in Padrino by tracking loads and
20
20
  memory consumption.
@@ -34,7 +34,9 @@ files:
34
34
  - lib/suites/json.rb
35
35
  - lib/suites/mem.rb
36
36
  - padrino-performance.gemspec
37
+ - test/bench_core.rb
37
38
  - test/helper.rb
39
+ - test/mem_core.rb
38
40
  - test/test_os.rb
39
41
  - test/test_padrino_performance.rb
40
42
  homepage: http://www.padrinorb.com
@@ -43,27 +45,29 @@ licenses:
43
45
  metadata: {}
44
46
  post_install_message:
45
47
  rdoc_options:
46
- - --charset=UTF-8
48
+ - "--charset=UTF-8"
47
49
  require_paths:
48
50
  - lib
49
51
  required_ruby_version: !ruby/object:Gem::Requirement
50
52
  requirements:
51
- - - '>='
53
+ - - ">="
52
54
  - !ruby/object:Gem::Version
53
55
  version: '0'
54
56
  required_rubygems_version: !ruby/object:Gem::Requirement
55
57
  requirements:
56
- - - '>='
58
+ - - ">="
57
59
  - !ruby/object:Gem::Version
58
60
  version: 1.3.6
59
61
  requirements: []
60
62
  rubyforge_project: padrino-performance
61
- rubygems_version: 2.0.6
63
+ rubygems_version: 2.4.8
62
64
  signing_key:
63
65
  specification_version: 4
64
66
  summary: A gem for finding performance problems in Padrino
65
67
  test_files:
68
+ - test/bench_core.rb
66
69
  - test/helper.rb
70
+ - test/mem_core.rb
67
71
  - test/test_os.rb
68
72
  - test/test_padrino_performance.rb
69
73
  has_rdoc: