rack-mini-profiler 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-mini-profiler might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -81,3 +81,13 @@
81
81
 
82
82
  * 1.17
83
83
  * pp=sample was bust unless stacktrace was installed
84
+
85
+ 10-September-2012 - Sam
86
+
87
+ * 1.19
88
+ * fix compat issue with 1.8.7
89
+
90
+ 12-September-2012 - Sam
91
+
92
+ * 1.20
93
+ * Added pp=profile-gc , it allows you to profile the GC in Ruby 1.9.3
@@ -208,6 +208,10 @@ module Rack
208
208
  return [status,headers,body]
209
209
  end
210
210
 
211
+ if query_string =~ /pp=profile-gc/
212
+ return profile_gc(env)
213
+ end
214
+
211
215
  MiniProfiler.create_current(env, @config)
212
216
  MiniProfiler.deauthorize_request if @config.authorization_mode == :whitelist
213
217
  if query_string =~ /pp=normal-backtrace/
@@ -385,12 +389,70 @@ module Rack
385
389
  pp=sample : sample stack traces and return a report isolating heavy usage (experimental works best with the stacktrace gem)
386
390
  pp=disable : disable profiling for this session
387
391
  pp=enable : enable profiling for this session (if previously disabled)
392
+ pp=profile-gc: perform gc profiling on this request (ruby 1.9.3 only)
388
393
  "
389
394
 
390
395
  client_settings.write!(headers)
391
396
  [200, headers, [body]]
392
397
  end
393
398
 
399
+
400
+ def object_space_stats
401
+ stats = {}
402
+ ObjectSpace.each_object { |o|
403
+ stats[o.class] ||= 1
404
+ stats[o.class] += 1
405
+ }
406
+ stats
407
+ end
408
+
409
+ def diff_object_stats(before,after)
410
+ diff = {}
411
+ after.each do |k,v|
412
+ diff[k] = v - (before[k] || 0)
413
+ end
414
+ before.each do |k,v|
415
+ diff[k] = 0 - v unless after[k]
416
+ end
417
+
418
+ diff
419
+ end
420
+
421
+ def profile_gc(env)
422
+
423
+ body = "";
424
+
425
+ stat_before = object_space_stats
426
+ begin
427
+ GC::Profiler.clear
428
+ GC::Profiler.enable
429
+ @app.call(env)
430
+ body << GC::Profiler.result
431
+ ensure
432
+ GC::Profiler.disable
433
+ end
434
+ stat_after = object_space_stats
435
+
436
+ diff = diff_object_stats(stat_before,stat_after)
437
+
438
+ body << "
439
+ ObjectSpace delta caused by request:
440
+ --------------------------------------------\n"
441
+ diff.to_a.reject{|k,v| v == 0}.sort{|x,y| y[1] <=> x[1]}.each do |k,v|
442
+ body << "#{k} : #{v}\n" if v != 0
443
+ end
444
+
445
+ body << "\n
446
+ ObjectSpace stats:
447
+ -----------------\n"
448
+
449
+ stat_after.to_a.sort{|x,y| y[1] <=> x[1]}.each do |k,v|
450
+ body << "#{k} : #{v}\n"
451
+ end
452
+
453
+ return [200, {'Content-Type' => 'text/plain'}, body]
454
+ end
455
+
394
456
  def analyze(traces, page_struct)
395
457
  headers = {'Content-Type' => 'text/plain'}
396
458
  body = "Collected: #{traces.count} stack traces. Duration(ms): #{page_struct.duration_ms}"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack-mini-profiler"
3
- s.version = "0.1.19"
3
+ s.version = "0.1.20"
4
4
  s.summary = "Profiles loading speed for rack applications."
5
5
  s.authors = ["Aleks Totic","Sam Saffron", "Robin Ward"]
6
6
  s.description = "Page loading speed displayed on every page. Optimize while you develop, performance is a feature."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mini-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-10 00:00:00.000000000 Z
14
+ date: 2012-09-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -352003811
134
+ hash: -250357363
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: -352003811
143
+ hash: -250357363
144
144
  requirements: []
145
145
  rubyforge_project:
146
146
  rubygems_version: 1.8.24