rack-mini-profiler 0.1.27 → 0.9.0.pre

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.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/{Ruby/CHANGELOG → CHANGELOG} +33 -0
  3. data/{Ruby/README.md → README.md} +51 -27
  4. data/{Ruby/lib → lib}/html/includes.css +0 -0
  5. data/{Ruby/lib → lib}/html/includes.js +90 -75
  6. data/{Ruby/lib → lib}/html/includes.less +0 -0
  7. data/{Ruby/lib → lib}/html/includes.tmpl +3 -1
  8. data/{Ruby/lib → lib}/html/jquery.1.7.1.js +0 -0
  9. data/{Ruby/lib → lib}/html/jquery.tmpl.js +0 -0
  10. data/{Ruby/lib → lib}/html/list.css +2 -2
  11. data/{Ruby/lib → lib}/html/list.js +1 -1
  12. data/{Ruby/lib → lib}/html/list.tmpl +2 -2
  13. data/lib/html/profile_handler.js +1 -0
  14. data/{Ruby/lib → lib}/html/share.html +2 -2
  15. data/{Ruby/lib → lib}/mini_profiler/client_settings.rb +11 -11
  16. data/{Ruby/lib → lib}/mini_profiler/client_timer_struct.rb +0 -0
  17. data/{Ruby/lib → lib}/mini_profiler/config.rb +18 -11
  18. data/{Ruby/lib → lib}/mini_profiler/context.rb +1 -1
  19. data/{Ruby/lib → lib}/mini_profiler/custom_timer_struct.rb +0 -0
  20. data/lib/mini_profiler/gc_profiler.rb +181 -0
  21. data/{Ruby/lib → lib}/mini_profiler/page_timer_struct.rb +4 -4
  22. data/{Ruby/lib → lib}/mini_profiler/profiler.rb +163 -141
  23. data/{Ruby/lib → lib}/mini_profiler/profiling_methods.rb +31 -11
  24. data/{Ruby/lib → lib}/mini_profiler/request_timer_struct.rb +5 -5
  25. data/{Ruby/lib → lib}/mini_profiler/sql_timer_struct.rb +0 -0
  26. data/{Ruby/lib → lib}/mini_profiler/storage/abstract_store.rb +4 -3
  27. data/{Ruby/lib → lib}/mini_profiler/storage/file_store.rb +0 -0
  28. data/{Ruby/lib → lib}/mini_profiler/storage/memcache_store.rb +0 -0
  29. data/{Ruby/lib → lib}/mini_profiler/storage/memory_store.rb +0 -0
  30. data/{Ruby/lib → lib}/mini_profiler/storage/redis_store.rb +3 -3
  31. data/{Ruby/lib → lib}/mini_profiler/timer_struct.rb +0 -0
  32. data/lib/mini_profiler/version.rb +5 -0
  33. data/{Ruby/lib → lib}/mini_profiler_rails/railtie.rb +6 -2
  34. data/{Ruby/lib → lib}/patches/net_patches.rb +0 -0
  35. data/{Ruby/lib → lib}/patches/sql_patches.rb +6 -1
  36. data/{Ruby/lib → lib}/rack-mini-profiler.rb +0 -0
  37. data/rack-mini-profiler.gemspec +6 -5
  38. metadata +45 -46
  39. data/Ruby/lib/html/flamegraph.html +0 -351
  40. data/Ruby/lib/html/profile_handler.js +0 -1
  41. data/Ruby/lib/mini_profiler/flame_graph.rb +0 -54
  42. data/Ruby/lib/mini_profiler/gc_profiler.rb +0 -107
  43. data/Ruby/lib/mini_profiler/version.rb +0 -5
@@ -1 +0,0 @@
1
- <script async type="text/javascript" id="mini-profiler" src="{path}includes.js?v={version}" data-version="{version}" data-path="{path}" data-current-id="{currentId}" data-ids="{ids}" data-position="{position}" data-trivial="{showTrivial}" data-children="{showChildren}" data-max-traces="{maxTracesToShow}" data-controls="{showControls}" data-authorized="{authorized}" data-toggle-shortcut="{toggleShortcut}" data-start-hidden="{startHidden}"></script>
@@ -1,54 +0,0 @@
1
- # inspired by https://github.com/brendangregg/FlameGraph
2
-
3
- class Rack::MiniProfiler::FlameGraph
4
- def initialize(stacks)
5
- @stacks = stacks
6
- end
7
-
8
- def graph_data
9
- height = 0
10
-
11
- table = []
12
- prev = []
13
-
14
- # a 2d array makes collapsing easy
15
- @stacks.each_with_index do |stack, pos|
16
- col = []
17
-
18
- stack.reverse.map{|r| r.to_s}.each_with_index do |frame, i|
19
-
20
- if !prev[i].nil?
21
- last_col = prev[i]
22
- if last_col[0] == frame
23
- last_col[1] += 1
24
- col << nil
25
- next
26
- end
27
- end
28
-
29
- prev[i] = [frame, 1]
30
- col << prev[i]
31
- end
32
- prev = prev[0..col.length-1].to_a
33
- table << col
34
- end
35
-
36
- data = []
37
-
38
- # a 1d array makes rendering easy
39
- table.each_with_index do |col, col_num|
40
- col.each_with_index do |row, row_num|
41
- next unless row && row.length == 2
42
- data << {
43
- :x => col_num + 1,
44
- :y => row_num + 1,
45
- :width => row[1],
46
- :frame => row[0]
47
- }
48
- end
49
- end
50
-
51
- data
52
- end
53
-
54
- end
@@ -1,107 +0,0 @@
1
- class Rack::MiniProfiler::GCProfiler
2
-
3
- def object_space_stats
4
- stats = {}
5
- ids = Set.new
6
- i=0
7
- ObjectSpace.each_object { |o|
8
- begin
9
- i = stats[o.class] || 0
10
- i += 1
11
- stats[o.class] = i
12
- ids << o.object_id if Integer === o.object_id
13
- rescue NoMethodError
14
- # Redis::Future undefines .class and .object_id super weird
15
- end
16
- }
17
- {:stats => stats, :ids => ids}
18
- end
19
-
20
- def diff_object_stats(before,after)
21
- diff = {}
22
- after.each do |k,v|
23
- diff[k] = v - (before[k] || 0)
24
- end
25
- before.each do |k,v|
26
- diff[k] = 0 - v unless after[k]
27
- end
28
-
29
- diff
30
- end
31
-
32
- def analyze_strings(ids_before,ids_after)
33
- result = {}
34
- ids_after.each do |id|
35
- obj = ObjectSpace._id2ref(id)
36
- if String === obj && !ids_before.include?(obj.object_id)
37
- result[obj] ||= 0
38
- result[obj] += 1
39
- end
40
- end
41
- result
42
- end
43
-
44
- def profile_gc_time(app,env)
45
- body = []
46
-
47
- begin
48
- GC::Profiler.clear
49
- GC::Profiler.enable
50
- b = app.call(env)[2]
51
- b.close if b.respond_to? :close
52
- body << "GC Profiler ran during this request, if it fired you will see the cost below:\n\n"
53
- body << GC::Profiler.result
54
- ensure
55
- GC.enable
56
- GC::Profiler.disable
57
- end
58
-
59
- return [200, {'Content-Type' => 'text/plain'}, body]
60
- end
61
-
62
- def profile_gc(app,env)
63
-
64
- body = [];
65
-
66
- stat_before,stat_after,diff,string_analysis = nil
67
- begin
68
- GC.disable
69
- stat_before = object_space_stats
70
- b = app.call(env)[2]
71
- b.close if b.respond_to? :close
72
- stat_after = object_space_stats
73
-
74
- diff = diff_object_stats(stat_before[:stats],stat_after[:stats])
75
- string_analysis = analyze_strings(stat_before[:ids], stat_after[:ids])
76
- ensure
77
- GC.enable
78
- end
79
-
80
-
81
- body << "
82
- ObjectSpace delta caused by request:
83
- --------------------------------------------\n"
84
- diff.to_a.reject{|k,v| v == 0}.sort{|x,y| y[1] <=> x[1]}.each do |k,v|
85
- body << "#{k} : #{v}\n" if v != 0
86
- end
87
-
88
- body << "\n
89
- ObjectSpace stats:
90
- -----------------\n"
91
-
92
- stat_after[:stats].to_a.sort{|x,y| y[1] <=> x[1]}.each do |k,v|
93
- body << "#{k} : #{v}\n"
94
- end
95
-
96
-
97
- body << "\n
98
- String stats:
99
- ------------\n"
100
-
101
- string_analysis.to_a.sort{|x,y| y[1] <=> x[1] }.take(1000).each do |string,count|
102
- body << "#{count} : #{string}\n"
103
- end
104
-
105
- return [200, {'Content-Type' => 'text/plain'}, body]
106
- end
107
- end
@@ -1,5 +0,0 @@
1
- module Rack
2
- class MiniProfiler
3
- VERSION = 'cc5e38497a61f98499f27184d21dbcd1'.freeze
4
- end
5
- end