skaes-railsbench 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -103,6 +103,13 @@ FILES
103
103
  store profile data in a HTML file in directory $RAILS_PERF_DATA
104
104
  file name is computed from date and benchmark name as described above
105
105
  but has a .html extension instead of .txt
106
+ - a number of options to steer ruby-prof are available:
107
+ -ruby_prof=number[/number]
108
+ sets threshold and min_percent for ruby-prof (defaults to 0.1/1)
109
+ -profile_type=stack|grind|flat|graph|multi
110
+ selects the profile format (defaults to stack)
111
+ -measure_mode=process_time|wall_time|cpu_time|allocations|memory
112
+ selects what to measure (default to wall_time)
106
113
 
107
114
  perf_plot [ options ] file1 file2 ...
108
115
  - plot performance data from raw performance files using gruff or gnuplot
@@ -50,12 +50,15 @@ class RailsBenchmark
50
50
  require 'dispatcher' # make edge rails happy
51
51
 
52
52
  if Rails::VERSION::STRING >= "2.3"
53
+ @rack_middleware = true
53
54
  require 'cgi/session'
54
55
  CGI.class_eval <<-"end_eval"
55
56
  def env_table
56
57
  @env_table ||= ENV.to_hash
57
58
  end
58
59
  end_eval
60
+ else
61
+ @rack_middleware = false
59
62
  end
60
63
 
61
64
  rescue => e
@@ -155,9 +158,8 @@ class RailsBenchmark
155
158
  end
156
159
 
157
160
  def establish_test_session
158
- if Rails::VERSION::STRING >= "2.3"
161
+ if @rack_middleware
159
162
  session_options = ActionController::Base.session_options
160
- # puts "the options: #{session_options.inspect}"
161
163
  @session_id = ActiveSupport::SecureRandom.hex(16)
162
164
  do_not_do_much = lambda do |env|
163
165
  env["rack.session"] = @session_data
@@ -177,15 +179,7 @@ class RailsBenchmark
177
179
  end
178
180
 
179
181
  def update_test_session_data(session_data)
180
- # puts ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.inspect
181
- dbman = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager]
182
- if dbman # before rails 2.3
183
- old_session_data = dbman.new(@session).restore
184
- # $stderr.puts old_session_data.inspect
185
- new_session_data = old_session_data.merge(session_data || {})
186
- new_session_data.each{ |k,v| @session[k] = v }
187
- @session.update
188
- else
182
+ if @rack_middleware
189
183
  session_options = ActionController::Base.session_options
190
184
  merge_url_specific_session_data = lambda do |env|
191
185
  old_session_data = env["rack.session"]
@@ -200,6 +194,13 @@ class RailsBenchmark
200
194
  env["HTTP_COOKIE"] = cookie
201
195
  # debugger
202
196
  @session_store.call(env)
197
+ else
198
+ dbman = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager]
199
+ old_session_data = dbman.new(@session).restore
200
+ # $stderr.puts old_session_data.inspect
201
+ new_session_data = old_session_data.merge(session_data || {})
202
+ new_session_data.each{ |k,v| @session[k] = v }
203
+ @session.update
203
204
  end
204
205
  end
205
206
 
@@ -295,7 +296,16 @@ class RailsBenchmark
295
296
  $stderr = File.open(benchmark_file, "w")
296
297
  end
297
298
  require 'ruby-prof'
298
- RubyProf.measure_mode = RubyProf::WALL_TIME
299
+ measure_mode = "WALL_TIME"
300
+ ARGV.each{|arg| measure_mode=$1.upcase if arg =~ /-measure_mode=([^ ]*)/ }
301
+ if %w(PROCESS_TIME WALL_TIME CPU_TIME ALLOCATIONS MEMORY).include?(measure_mode)
302
+ RubyProf.measure_mode = RubyProf.const_get measure_mode
303
+ GC.eanable_stats if measure_mode == "memory"
304
+ else
305
+ $stderr = STDERR
306
+ $stderr.puts "unsupported ruby_prof measure mode: #{measure_mode}"
307
+ exit(-1)
308
+ end
299
309
  RubyProf.start
300
310
  end
301
311
  rescue LoadError
@@ -540,7 +550,7 @@ class RailsBenchmarkWithActiveRecordStore < RailsBenchmark
540
550
 
541
551
  def initialize(options={})
542
552
  super(options)
543
- @session_class = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager].session_class rescue CGI::Session::ActiveRecordStore
553
+ @session_class = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager].session_class rescue CGI::Session::ActiveRecordStore rescue ActiveRecord::SessionStore
544
554
  end
545
555
 
546
556
  def delete_new_test_sessions
@@ -2,7 +2,7 @@ module Railsbench #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 5
5
+ TINY = 6
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skaes-railsbench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-25 00:00:00 -07:00
12
+ date: 2009-08-16 00:00:00 -07:00
13
13
  default_executable: railsbench
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.8.2
23
+ version: 1.12.2
24
24
  version:
25
25
  description: rails benchmarking tools
26
26
  email: skaes@railsexpress.de
@@ -87,6 +87,7 @@ files:
87
87
  - test/test_helper.rb
88
88
  has_rdoc: false
89
89
  homepage: http://railsbench.rubyforge.org
90
+ licenses:
90
91
  post_install_message:
91
92
  rdoc_options:
92
93
  - --main
@@ -108,9 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  requirements: []
109
110
 
110
111
  rubyforge_project: railsbench
111
- rubygems_version: 1.2.0
112
+ rubygems_version: 1.3.5
112
113
  signing_key:
113
- specification_version: 2
114
+ specification_version: 3
114
115
  summary: rails benchmarking tools
115
116
  test_files:
116
117
  - test/railsbench_test.rb