redcar 0.3.4.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. data/CHANGES +45 -0
  2. data/README.md +2 -1
  3. data/ROADMAP.md +0 -1
  4. data/Rakefile +10 -4
  5. data/bin/redcar +2 -2
  6. data/lib/openssl/build.properties +7 -0
  7. data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
  8. data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
  9. data/lib/redcar.rb +12 -8
  10. data/lib/redcar/installer.rb +16 -15
  11. data/lib/redcar/ruby_extensions.rb +146 -1
  12. data/lib/redcar/runner.rb +16 -7
  13. data/lib/redcar/usage.rb +4 -7
  14. data/lib/redcar_quick_start.rb +5 -5
  15. data/lib/regex_replace.rb +0 -7
  16. data/plugins/application/features/step_definitions/command_steps.rb +5 -0
  17. data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
  18. data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
  19. data/plugins/application/features/step_definitions/window_steps.rb +1 -1
  20. data/plugins/application/features/support/env.rb +44 -8
  21. data/plugins/application/lib/application.rb +32 -33
  22. data/plugins/application/lib/application/command.rb +32 -2
  23. data/plugins/application/lib/application/command/executor.rb +2 -12
  24. data/plugins/application/lib/application/dialog.rb +14 -14
  25. data/plugins/application/lib/application/event_spewer.rb +32 -0
  26. data/plugins/application/lib/application/menu.rb +5 -5
  27. data/plugins/application/lib/application/menu/builder.rb +5 -0
  28. data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
  29. data/plugins/application/lib/application/notebook.rb +4 -3
  30. data/plugins/application/lib/application/tab.rb +6 -2
  31. data/plugins/application/lib/application/window.rb +8 -4
  32. data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
  33. data/plugins/application/spec/application/notebook_spec.rb +1 -1
  34. data/plugins/application_swt/build.xml +74 -0
  35. data/plugins/application_swt/lib/application_swt.rb +79 -0
  36. data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
  37. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
  38. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
  39. data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
  40. data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
  41. data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
  42. data/plugins/application_swt/lib/application_swt/window.rb +11 -11
  43. data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
  44. data/plugins/auto_completer/lib/auto_completer.rb +74 -67
  45. data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
  46. data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
  47. data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
  48. data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
  49. data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
  50. data/plugins/auto_indenter/features/support/env.rb +2 -0
  51. data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
  52. data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
  53. data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
  54. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
  55. data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
  56. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
  57. data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
  58. data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
  59. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
  60. data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
  61. data/plugins/core/lib/core.rb +12 -1
  62. data/plugins/core/lib/core/observable.rb +7 -7
  63. data/plugins/core/lib/core/persistent_cache.rb +14 -2
  64. data/plugins/core/lib/core/plugin.rb +7 -0
  65. data/plugins/core/lib/core/resource.rb +78 -0
  66. data/plugins/core/lib/core/task.rb +62 -0
  67. data/plugins/core/lib/core/task_queue.rb +72 -0
  68. data/plugins/core/spec/core/resource_spec.rb +124 -0
  69. data/plugins/core/spec/core/task_queue_spec.rb +202 -0
  70. data/plugins/core/spec/spec_helper.rb +23 -1
  71. data/plugins/declarations/TODO +3 -0
  72. data/plugins/declarations/lib/declarations.rb +144 -0
  73. data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
  74. data/plugins/declarations/lib/declarations/file.rb +68 -0
  75. data/plugins/declarations/lib/declarations/parser.rb +94 -0
  76. data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
  77. data/plugins/declarations/plugin.rb +7 -0
  78. data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
  79. data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
  80. data/plugins/declarations/spec/spec_helper.rb +4 -0
  81. data/plugins/edit_view/features/indentation_commands.feature +40 -0
  82. data/plugins/edit_view/features/line_delimiter.feature +40 -0
  83. data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
  84. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
  85. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  86. data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
  87. data/plugins/edit_view/features/support/env.rb +3 -5
  88. data/plugins/edit_view/features/undo_and_redo.feature +21 -0
  89. data/plugins/edit_view/lib/edit_view.rb +57 -4
  90. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
  91. data/plugins/edit_view/lib/edit_view/document.rb +46 -11
  92. data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
  93. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
  94. data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
  95. data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
  96. data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
  97. data/plugins/edit_view/spec/spec_helper.rb +1 -0
  98. data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
  99. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
  100. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
  101. data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
  102. data/plugins/encryption/encryption.rb +13 -6
  103. data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
  104. data/plugins/html_view/assets/redcar.css +32 -1
  105. data/plugins/html_view/lib/html_view.rb +23 -3
  106. data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
  107. data/plugins/my_plugin/lib/my_plugin.rb +4 -12
  108. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
  109. data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
  110. data/plugins/project/features/find_file.feature +75 -0
  111. data/plugins/project/features/open_and_save_files.feature +7 -7
  112. data/plugins/project/features/open_directory_tree.feature +11 -3
  113. data/plugins/project/features/refresh_directory_tree.feature +7 -1
  114. data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
  115. data/plugins/project/features/step_definitions/file_steps.rb +10 -0
  116. data/plugins/project/features/support/env.rb +6 -1
  117. data/plugins/project/features/watch_for_modified_files.feature +79 -0
  118. data/plugins/project/lib/project.rb +72 -306
  119. data/plugins/project/lib/project/commands.rb +128 -0
  120. data/plugins/project/lib/project/dir_mirror.rb +5 -1
  121. data/plugins/project/lib/project/drb_service.rb +21 -31
  122. data/plugins/project/lib/project/file_list.rb +76 -0
  123. data/plugins/project/lib/project/file_mirror.rb +13 -1
  124. data/plugins/project/lib/project/find_file_dialog.rb +22 -52
  125. data/plugins/project/lib/project/manager.rb +210 -0
  126. data/plugins/project/lib/project/recent_directories.rb +16 -3
  127. data/plugins/project/plugin.rb +1 -1
  128. data/plugins/project/spec/fixtures/myproject/README +2 -0
  129. data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
  130. data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
  131. data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
  132. data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
  133. data/plugins/project/spec/project/file_list_spec.rb +140 -0
  134. data/plugins/project/spec/spec_helper.rb +20 -0
  135. data/plugins/redcar/plugin.rb +1 -0
  136. data/plugins/redcar/redcar.rb +254 -84
  137. data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
  138. data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
  139. data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
  140. data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
  141. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
  142. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
  143. data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
  144. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
  145. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
  146. data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
  147. data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
  148. data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
  149. data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
  150. data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
  151. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
  152. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
  153. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
  154. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
  155. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
  156. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
  157. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
  158. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
  159. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
  160. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
  161. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
  162. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
  163. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
  164. data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
  165. data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
  166. data/plugins/redcar_debug/views/history.html.erb +33 -0
  167. data/plugins/redcar_debug/views/index.html.erb +33 -0
  168. data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
  169. data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
  170. data/plugins/snippets/lib/snippets.rb +0 -1
  171. data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
  172. data/plugins/task_manager/lib/task_manager.rb +28 -0
  173. data/plugins/task_manager/plugin.rb +11 -0
  174. data/plugins/task_manager/views/index.html.erb +67 -0
  175. data/plugins/textmate/lib/textmate.rb +17 -21
  176. data/plugins/textmate/lib/textmate/plist.rb +1 -2
  177. data/plugins/textmate/lib/textmate/preference.rb +5 -1
  178. data/plugins/textmate/lib/textmate/snippet.rb +6 -1
  179. data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
  180. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
  181. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
  182. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
  183. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
  184. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
  185. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
  186. data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
  187. data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
  188. data/textmate/Themes/Emacs Strict.tmTheme +241 -0
  189. data/textmate/Themes/IR_White.tmTheme +792 -0
  190. data/textmate/Themes/Monokai.tmTheme +291 -0
  191. data/textmate/Themes/WhysPoignant.tmTheme +191 -0
  192. metadata +92 -7
  193. data/plugins/application/features/main_window.feature +0 -8
  194. data/plugins/project/lib/project/project_command.rb +0 -5
  195. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
  196. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Story.tmSnippet +0 -25
@@ -0,0 +1,123 @@
1
+
2
+ class JRubyProf
3
+ class GraphHtmlPrinter < GraphTextPrinter
4
+ def print_on(output)
5
+ output.puts HEADER
6
+ total_duration = thread_set.duration
7
+ thread_set.invocations.each_with_index do |thread, i|
8
+ methods = thread.get_methods.values.sort_by {|m| m.duration }.reverse
9
+ output.puts "<h3>Thread #{i + 1}/#{thread_set.length}</h3>"
10
+ output.puts TABLE_HEADER
11
+ rows = methods.map do |method|
12
+ method.parent_contexts.each do |context|
13
+ print_method(output, context, total_duration, false)
14
+ end
15
+ print_method(output, method, total_duration, true)
16
+ method.child_contexts.each do |context|
17
+ print_method(output, context, total_duration, false)
18
+ end
19
+ output.puts <<-HTML
20
+ <tr class="break">
21
+ <td colspan="7"></td>
22
+ </tr>
23
+ HTML
24
+ end
25
+ output.puts TABLE_FOOTER
26
+ end
27
+ output.puts FOOTER
28
+ end
29
+
30
+ def print_method(output, method, total_duration, major_row)
31
+ return if method.name =~ /JRubyProf\.stop/
32
+ total = method.duration
33
+ total_pc = (total.to_f/total_duration)*100
34
+ children = method.childrens_duration
35
+ self_ = total - children
36
+ self_pc = (self_.to_f/total_duration)*100
37
+ calls = method.count
38
+ name = method.name
39
+ inv_id = nil
40
+ template = File.read(File.join(File.dirname(__FILE__), "..", "..", "templates", "graph_row.html.erb"))
41
+ erb = ERB.new(template)
42
+ output.puts(erb.result(binding))
43
+ end
44
+
45
+ def safe_name(name)
46
+ name.gsub("#", "_inst_").gsub(".", "_stat_")
47
+ end
48
+
49
+ HEADER = <<HTML
50
+ <html>
51
+ <body>
52
+ <head>
53
+ <style media="all" type="text/css">
54
+ table {
55
+ border-collapse: collapse;
56
+ border: 1px solid #CCC;
57
+ font-family: Verdana, Arial, Helvetica, sans-serif;
58
+ font-size: 9pt;
59
+ line-height: normal;
60
+ }
61
+
62
+ th {
63
+ text-align: center;
64
+ border-top: 1px solid #FB7A31;
65
+ border-bottom: 1px solid #FB7A31;
66
+ background: #FFC;
67
+ padding: 0.3em;
68
+ border-left: 1px solid silver;
69
+ }
70
+
71
+ tr.break td {
72
+ border: 0;
73
+ border-top: 1px solid #FB7A31;
74
+ padding: 0;
75
+ margin: 0;
76
+ }
77
+
78
+ tr.method td {
79
+ font-weight: bold;
80
+ }
81
+
82
+ td {
83
+ padding: 0.3em;
84
+ }
85
+
86
+ td:first-child {
87
+ width: 190px;
88
+ }
89
+
90
+ td {
91
+ border-left: 1px solid #CCC;
92
+ text-align: center;
93
+ }
94
+ </style>
95
+ </head>
96
+ HTML
97
+
98
+ TABLE_HEADER = <<-HTML
99
+ <table>
100
+ <tr>
101
+ <th>%total</th>
102
+ <th>%self</th>
103
+ <th>total</th>
104
+ <th>self</th>
105
+ <th>children</th>
106
+ <th>calls</th>
107
+ <th>Name</th>
108
+ </tr>
109
+ HTML
110
+
111
+ TABLE_FOOTER = <<HTML
112
+ </table>
113
+ <br />
114
+ <br />
115
+ HTML
116
+
117
+ FOOTER = <<-HTML
118
+ </body>
119
+ </html>
120
+ HTML
121
+
122
+ end
123
+ end
@@ -0,0 +1,45 @@
1
+
2
+ class JRubyProf
3
+ class GraphTextPrinter < AbstractPrinter
4
+ TABLE_HEADER = " %total %self total self children calls Name"
5
+
6
+ def print_on(output)
7
+ thread_set.invocations.each_with_index do |invocation, i|
8
+ output.puts
9
+ output.puts "Thread #{i + 1} / #{thread_set.length}"
10
+ output.puts
11
+ methods = invocation.get_methods.values.sort_by {|m| m.duration }.reverse
12
+ output.puts TABLE_HEADER
13
+ output.puts "-"*100
14
+ total_duration = thread_set.duration
15
+ rows = methods.map do |method|
16
+ method.parent_contexts.each do |context|
17
+ print_method(output, context, total_duration, false)
18
+ end
19
+ print_method(output, method, total_duration, true)
20
+ method.child_contexts.each do |context|
21
+ print_method(output, context, total_duration, false)
22
+ end
23
+ output.puts "-"*100
24
+ end
25
+ end
26
+ end
27
+
28
+ def print_method(output, method, total_duration, print_percents)
29
+ return if method.name =~ /JRubyProf\.stop/
30
+ total = method.duration
31
+ total_pc = (total.to_f/total_duration)*100
32
+ children = method.childrens_duration
33
+ self_ = total - children
34
+ self_pc = (self_.to_f/total_duration)*100
35
+ calls = method.count
36
+ name = method.name
37
+ if print_percents
38
+ output.print " #{("%2.2f" % total_pc).rjust(6)}% #{("%2.2f" % self_pc).rjust(6)}%"
39
+ else
40
+ output.print " "
41
+ end
42
+ output.puts "#{total.to_s.rjust(11)} #{self_.to_s.rjust(9)} #{children.to_s.rjust(11)} #{calls.to_s.rjust(8)} #{name}"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+
2
+ class JRubyProf
3
+ class ThreadSet
4
+ attr_reader :invocations, :duration
5
+
6
+ def initialize(invocations, duration)
7
+ @invocations = invocations.map do |inv|
8
+ c = inv
9
+ c = c.parent while c.parent
10
+ c
11
+ end
12
+ @duration = duration
13
+ end
14
+
15
+ def length
16
+ invocations.length
17
+ end
18
+
19
+ def top_level_duration
20
+ invocations.inject(0.0) do |m, inv|
21
+ m + inv.childrens_duration
22
+ end
23
+ end
24
+
25
+ def self.add_methods(h, inv, duration=nil, count=nil)
26
+ return if inv.name =~ /CachingCallSite\.stop_tracing/ or inv.name =~ /JRubyProf\.stop/
27
+ h[inv.name] ||= Method.new(inv.class_name, inv.method_name, inv.static?)
28
+ h[inv.name].add_invocation(inv)
29
+ inv.children.each do |child_inv|
30
+ add_methods(h, child_inv)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,107 @@
1
+
2
+ class JRubyProf
3
+ class Method
4
+ attr_reader :class_name, :method_name, :invocations
5
+
6
+ def initialize(class_name, method_name, static)
7
+ @class_name, @method_name, @static = class_name, method_name, static
8
+ @invocations = []
9
+ end
10
+
11
+ def static?
12
+ @static
13
+ end
14
+
15
+ def toplevel?
16
+ method_name == nil
17
+ end
18
+
19
+ def add_invocation(inv)
20
+ invocations << inv
21
+ end
22
+
23
+ def duration
24
+ if toplevel?
25
+ childrens_duration
26
+ else
27
+ invocations.inject(0) {|m, inv| m + inv.duration}
28
+ end
29
+ end
30
+
31
+ def count
32
+ if toplevel?
33
+ 1
34
+ else
35
+ invocations.inject(0) {|m, inv| m + inv.count}
36
+ end
37
+ end
38
+
39
+ def childrens_duration
40
+ invocations.inject(0) {|m, inv| m + inv.children.inject(0) {|m1, inv1| m1 + inv1.duration }}
41
+ end
42
+
43
+ def name
44
+ "#{class_name}#{static? ? "." : "#"}#{method_name || "toplevel"}"
45
+ end
46
+
47
+ class CallContext
48
+ attr_accessor :name, :duration, :childrens_duration, :count
49
+
50
+ def toplevel?
51
+ @name == "#"
52
+ end
53
+
54
+ def name
55
+ toplevel? ? "#toplevel" : @name
56
+ end
57
+
58
+ def initialize(name)
59
+ @name = name
60
+ @duration, @childrens_duration, @count = 0, 0, 0
61
+ end
62
+
63
+ def duration
64
+ toplevel? ? @childrens_duration : @duration
65
+ end
66
+ end
67
+
68
+ def child_contexts
69
+ @child_contexts ||= begin
70
+ h = {}
71
+ invocations.each do |inv|
72
+ inv.children.each do |inv2|
73
+ h[inv2.name] ||= CallContext.new(inv2.name)
74
+ cc = h[inv2.name]
75
+ cc.duration += inv2.duration
76
+ cc.childrens_duration += inv2.childrens_duration
77
+ cc.count += inv2.count
78
+ end
79
+ end
80
+ h.values
81
+ end
82
+ end
83
+
84
+ def parent_contexts
85
+ @parent_contexts ||= begin
86
+ h = {}
87
+ invocations.each do |inv|
88
+ inv2 = inv.parent
89
+ next unless inv2
90
+ h[inv2.name] ||= CallContext.new(inv2.name)
91
+ cc = h[inv2.name]
92
+ cc.duration += inv.duration
93
+ cc.childrens_duration += inv.childrens_duration
94
+ cc.count += inv.count
95
+ end
96
+ h.values
97
+ end
98
+ end
99
+
100
+ def inspect
101
+ "#<JRubyProf::Method #{class_name} #{method_name}>"
102
+ end
103
+ end
104
+ end
105
+
106
+
107
+
@@ -0,0 +1,43 @@
1
+
2
+ class JRubyProf
3
+ import org.jruby.prof.Invocation
4
+ class Invocation
5
+ alias :method_name :methodName
6
+ alias :class_name :className
7
+
8
+ def name
9
+ "#{class_name}#{static? ? "." : "#"}#{method_name}"
10
+ end
11
+
12
+ def childrens_duration
13
+ children.inject(0) {|m, inv| m + inv.duration}
14
+ end
15
+
16
+ def static?
17
+ false
18
+ end
19
+
20
+ def to_method
21
+ method = Method.new(class_name, method_name, static?)
22
+ method.add_invocation(self)
23
+ method
24
+ end
25
+
26
+ def id
27
+ @id ||= Invocation.new_id
28
+ end
29
+
30
+ def self.new_id
31
+ @id ||= 0
32
+ @id += 1
33
+ @id
34
+ end
35
+
36
+ def get_methods
37
+ h = {}
38
+ ThreadSet.add_methods(h, self)
39
+ h
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,27 @@
1
+
2
+ class JRubyProf
3
+ class SimpleTreePrinter < AbstractPrinter
4
+ def print_on(output)
5
+ thread_set.invocations.each_with_index do |invocation, i|
6
+ output.puts
7
+ output.puts "*** Thread #{i + 1} / #{thread_set.length}"
8
+ output.puts
9
+ dump_from_root(output, invocation)
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def dump(f, inv, indent=0)
16
+ f.print(" "*indent)
17
+ f.puts "#{inv.name} - #{inv.duration}"
18
+ inv.children.each {|child_inv| dump(f, child_inv, indent + 2)}
19
+ end
20
+
21
+ def dump_from_root(f, inv)
22
+ current = inv
23
+ current = current.parent while current.parent
24
+ dump(f, current)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,144 @@
1
+
2
+ class JRubyProf
3
+ class TreeHtmlPrinter < AbstractPrinter
4
+ def print_on(output)
5
+ total_duration = thread_set.duration
6
+ output.puts HEADER
7
+ thread_set.invocations.each_with_index do |invocation, i|
8
+ all_invocations = []
9
+ get_invocations(all_invocations, invocation)
10
+ output.puts "<h3>Thread #{i + 1}/#{thread_set.length}</h3>"
11
+ output.puts TABLE_HEADER
12
+ all_invocations = all_invocations.sort_by {|i| m = i.to_method.duration }.reverse
13
+ all_invocations.each do |inv|
14
+ next if inv.name =~ /CachingCallSite\.stop_tracing/
15
+ next if inv.name =~ /JRubyProf\.stop/
16
+ next if inv.duration < 5
17
+ #next if inv.name == "#"
18
+ c = inv
19
+ parents = []
20
+ while c.parent
21
+ c = c.parent
22
+ parents << c
23
+ end
24
+ parents.reverse.each do |parent_inv|
25
+ print_invocation(output, parent_inv, total_duration, false)
26
+ end
27
+ print_invocation(output, inv, total_duration, true)
28
+ inv.children.each do |child_inv|
29
+ next if child_inv.name =~ /CachingCallSite\.stop_tracing/
30
+ print_invocation(output, child_inv, total_duration, false)
31
+ end
32
+ output.puts <<-HTML
33
+ <tr class="break">
34
+ <td colspan="7"></td>
35
+ </tr>
36
+ HTML
37
+ end
38
+ output.puts TABLE_FOOTER
39
+ end
40
+ output.puts FOOTER
41
+ end
42
+
43
+ def get_invocations(arr, invocation)
44
+ arr << invocation
45
+ invocation.children.each do |inv|
46
+ get_invocations(arr, inv)
47
+ end
48
+ end
49
+
50
+ def print_invocation(output, invocation, total_duration, major_row)
51
+ next if invocation.name =~ /JRubyProf\.stop/
52
+ method = invocation.to_method
53
+ total = method.duration
54
+ total_pc = (total.to_f/total_duration)*100
55
+ children = method.childrens_duration
56
+ self_ = total - children
57
+ self_pc = (self_.to_f/total_duration)*100
58
+ calls = method.count
59
+ name = method.name
60
+ inv_id = invocation.id
61
+ template = File.read(File.join(File.dirname(__FILE__), "..", "..", "templates", "graph_row.html.erb"))
62
+ erb = ERB.new(template)
63
+ output.puts(erb.result(binding))
64
+ end
65
+
66
+ def safe_name(name)
67
+ name.gsub("#", "_inst_").gsub(".", "_stat_")
68
+ end
69
+
70
+ HEADER = <<HTML
71
+ <html>
72
+ <body>
73
+ <head>
74
+ <style media="all" type="text/css">
75
+ table {
76
+ border-collapse: collapse;
77
+ border: 1px solid #CCC;
78
+ font-family: Verdana, Arial, Helvetica, sans-serif;
79
+ font-size: 9pt;
80
+ line-height: normal;
81
+ }
82
+
83
+ th {
84
+ text-align: center;
85
+ border-top: 1px solid #339;
86
+ border-bottom: 1px solid #339;
87
+ background: #CDF;
88
+ padding: 0.3em;
89
+ border-left: 1px solid silver;
90
+ }
91
+
92
+ tr.break td {
93
+ border: 0;
94
+ border-top: 1px solid #339;
95
+ padding: 0;
96
+ margin: 0;
97
+ }
98
+
99
+ tr.method td {
100
+ font-weight: bold;
101
+ }
102
+
103
+ td {
104
+ padding: 0.3em;
105
+ }
106
+
107
+ td:first-child {
108
+ width: 190px;
109
+ }
110
+
111
+ td {
112
+ border-left: 1px solid #CCC;
113
+ text-align: center;
114
+ }
115
+ </style>
116
+ </head>
117
+ HTML
118
+
119
+ TABLE_HEADER = <<-HTML
120
+ <table>
121
+ <tr>
122
+ <th>%total</th>
123
+ <th>%self</th>
124
+ <th>total</th>
125
+ <th>self</th>
126
+ <th>children</th>
127
+ <th>calls</th>
128
+ <th>Name</th>
129
+ </tr>
130
+ HTML
131
+
132
+ TABLE_FOOTER = <<HTML
133
+ </table>
134
+ <br />
135
+ <br />
136
+ HTML
137
+
138
+ FOOTER = <<-HTML
139
+ </body>
140
+ </html>
141
+ HTML
142
+
143
+ end
144
+ end