padrino-performance 0.13.0.beta3 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa8ee76f087a8559de51f3e3d9c3befe8d0b7059
4
- data.tar.gz: b0d4ea249a37c951a3932586c69c22e497f14ba1
3
+ metadata.gz: 4380c09f8a9cf03c56e895e4fce407597612d377
4
+ data.tar.gz: 806104559c20490dfbe9c54d75082615447b9f6e
5
5
  SHA512:
6
- metadata.gz: 6a448c0c92c152a2ba215542440794f074fd1f1d99caba4f54c7d6ff55d9fd9ff203757034e5134ce2b074b383441a2ff5de47343c497910f0c3783cb99803ac
7
- data.tar.gz: 2066e18891648c9b075eba191ff8c1994918e0a2a66f435490871c24b5ab72e2839b1b4a9770da3122fc619c4c20c4967b80e69b035853e6447800e00a4f78fe
6
+ metadata.gz: 6eca89b5d4ece01ec0aea62195f6e2856d9b9015951bb8ea0d622ac2d7a78d0fbea15600aa3f88c4d8e4ebe819b75b9ed71ef0c92c0ca47365833d576aae6bcb
7
+ data.tar.gz: 979bff0670ea3e4321a6dbc5256bb571ad6bca2e4909611c8bb82596220847b4f2361957ed24cb8119d5e2d80233afc49bd33ac0a3a1f57e3a377bc9797ab210
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
2
+
3
+ Rake::TestTask.new(:bench) do |test|
4
+ test.libs << 'test'
5
+ test.test_files = Dir['test/**/bench_*.rb']
6
+ end
@@ -1,7 +1,7 @@
1
1
  module Padrino
2
2
  module Performance
3
3
  # The version constant for the current version of Padrino.
4
- VERSION = '0.13.0.beta2' unless defined?(Padrino::VERSION)
4
+ VERSION = '0.13.0' unless defined?(Padrino::VERSION)
5
5
 
6
6
  #
7
7
  # The current Padrino version.
@@ -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
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.13.0.beta3
4
+ version: 0.13.0
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-08-02 00:00:00.000000000 Z
17
+ date: 2015-10-11 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,6 +34,7 @@ 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
38
39
  - test/test_os.rb
39
40
  - test/test_padrino_performance.rb
@@ -53,16 +54,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
54
  version: '0'
54
55
  required_rubygems_version: !ruby/object:Gem::Requirement
55
56
  requirements:
56
- - - '>'
57
+ - - '>='
57
58
  - !ruby/object:Gem::Version
58
- version: 1.3.1
59
+ version: 1.3.6
59
60
  requirements: []
60
61
  rubyforge_project: padrino-performance
61
- rubygems_version: 2.0.6
62
+ rubygems_version: 2.4.8
62
63
  signing_key:
63
64
  specification_version: 4
64
65
  summary: A gem for finding performance problems in Padrino
65
66
  test_files:
67
+ - test/bench_core.rb
66
68
  - test/helper.rb
67
69
  - test/test_os.rb
68
70
  - test/test_padrino_performance.rb