redcar 0.3.4.3 → 0.3.5

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.
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,125 @@
1
+
2
+ Thread 1 / 1
3
+
4
+ %total %self total self children calls Name
5
+ ----------------------------------------------------------------------------------------------------
6
+ 1823 19 1804 2000 Integer#times
7
+ 3661 38 3623 6635 PiDigitSpigot#next!
8
+ 297.56% 3.09% 5484 57 5427 8635 PiDigitSpigot#next!
9
+ 399 55 344 8635 Transformation#extract
10
+ 487 45 442 8635 PiDigitSpigot#safe?
11
+ 44 31 13 6635 Transformation#next!
12
+ 633 12 621 6635 PiDigitSpigot#consume
13
+ 3661 38 3623 6635 PiDigitSpigot#next!
14
+ 203 7 196 2000 PiDigitSpigot#produce
15
+ ----------------------------------------------------------------------------------------------------
16
+ 1832 0 1832 1 #toplevel
17
+ 100.00% 0.60% 1843 11 1832 1 Object#compute_pidigits
18
+ 0 0 0 1 Kernel#Integer
19
+ 0 0 0 1 PiDigitSpigot#initialize
20
+ 0 0 0 200 Fixnum#>=
21
+ 1830 7 1823 200 Integer#times
22
+ 0 0 0 200 Fixnum#+
23
+ 2 2 0 200 Fixnum#-
24
+ ----------------------------------------------------------------------------------------------------
25
+ 100.00% 0.00% 1843 0 1843 1 #toplevel
26
+ 1843 11 1832 1 Object#compute_pidigits
27
+ ----------------------------------------------------------------------------------------------------
28
+ 1830 7 1823 200 Object#compute_pidigits
29
+ 99.29% 0.38% 1830 7 1823 200 Integer#times
30
+ 1823 19 1804 2000 PiDigitSpigot#next!
31
+ ----------------------------------------------------------------------------------------------------
32
+ 399 55 344 8635 PiDigitSpigot#next!
33
+ 440 60 380 8635 PiDigitSpigot#safe?
34
+ 45.52% 6.24% 839 115 724 17270 Transformation#extract
35
+ 13 13 0 17314 Fixnum#*
36
+ 9 9 0 17314 Fixnum#+
37
+ 0 0 0 42 Fixnum#/
38
+ 302 302 0 17226 Bignum#*
39
+ 94 94 0 17226 Bignum#+
40
+ 306 306 0 17228 Bignum#/
41
+ ----------------------------------------------------------------------------------------------------
42
+ 621 89 532 6635 PiDigitSpigot#consume
43
+ 178 21 157 2000 PiDigitSpigot#produce
44
+ 43.35% 5.97% 799 110 689 8635 Transformation#compose
45
+ 3 3 0 8635 Kernel#class
46
+ 150 150 0 27354 Fixnum#*
47
+ 11 11 0 17291 Fixnum#+
48
+ 13 13 0 8635 Transformation#initialize
49
+ 462 462 0 33091 Bignum#*
50
+ 50 50 0 8614 Bignum#+
51
+ ----------------------------------------------------------------------------------------------------
52
+ 302 302 0 17226 Transformation#extract
53
+ 462 462 0 33091 Transformation#compose
54
+ 41.45% 41.45% 764 764 0 50317 Bignum#*
55
+ ----------------------------------------------------------------------------------------------------
56
+ 633 12 621 6635 PiDigitSpigot#next!
57
+ 34.35% 0.65% 633 12 621 6635 PiDigitSpigot#consume
58
+ 621 89 532 6635 Transformation#compose
59
+ ----------------------------------------------------------------------------------------------------
60
+ 487 45 442 8635 PiDigitSpigot#next!
61
+ 26.42% 2.44% 487 45 442 8635 PiDigitSpigot#safe?
62
+ 440 60 380 8635 Transformation#extract
63
+ 2 2 0 8635 Fixnum#==
64
+ ----------------------------------------------------------------------------------------------------
65
+ 306 306 0 17228 Transformation#extract
66
+ 16.60% 16.60% 306 306 0 17228 Bignum#/
67
+ ----------------------------------------------------------------------------------------------------
68
+ 203 7 196 2000 PiDigitSpigot#next!
69
+ 11.01% 0.38% 203 7 196 2000 PiDigitSpigot#produce
70
+ 0 0 0 2000 Fixnum#*
71
+ 18 16 2 2000 Transformation#qrst
72
+ 178 21 157 2000 Transformation#compose
73
+ ----------------------------------------------------------------------------------------------------
74
+ 13 13 0 17314 Transformation#extract
75
+ 6 6 0 13270 Transformation#next!
76
+ 150 150 0 27354 Transformation#compose
77
+ 0 0 0 2000 PiDigitSpigot#produce
78
+ 9.17% 9.17% 169 169 0 59938 Fixnum#*
79
+ ----------------------------------------------------------------------------------------------------
80
+ 94 94 0 17226 Transformation#extract
81
+ 50 50 0 8614 Transformation#compose
82
+ 7.81% 7.81% 144 144 0 25840 Bignum#+
83
+ ----------------------------------------------------------------------------------------------------
84
+ 44 31 13 6635 PiDigitSpigot#next!
85
+ 2.39% 1.68% 44 31 13 6635 Transformation#next!
86
+ 7 7 0 19905 Fixnum#+
87
+ 6 6 0 13270 Fixnum#*
88
+ ----------------------------------------------------------------------------------------------------
89
+ 9 9 0 17314 Transformation#extract
90
+ 7 7 0 19905 Transformation#next!
91
+ 11 11 0 17291 Transformation#compose
92
+ 0 0 0 200 Object#compute_pidigits
93
+ 1.47% 1.47% 27 27 0 54710 Fixnum#+
94
+ ----------------------------------------------------------------------------------------------------
95
+ 18 16 2 2000 PiDigitSpigot#produce
96
+ 0.98% 0.87% 18 16 2 2000 Transformation#qrst
97
+ 2 2 0 2000 Transformation#initialize
98
+ ----------------------------------------------------------------------------------------------------
99
+ 0 0 0 3 PiDigitSpigot#initialize
100
+ 13 13 0 8635 Transformation#compose
101
+ 2 2 0 2000 Transformation#qrst
102
+ 0.81% 0.81% 15 15 0 10638 Transformation#initialize
103
+ ----------------------------------------------------------------------------------------------------
104
+ 3 3 0 8635 Transformation#compose
105
+ 0.16% 0.16% 3 3 0 8635 Kernel#class
106
+ ----------------------------------------------------------------------------------------------------
107
+ 2 2 0 200 Object#compute_pidigits
108
+ 0.11% 0.11% 2 2 0 200 Fixnum#-
109
+ ----------------------------------------------------------------------------------------------------
110
+ 2 2 0 8635 PiDigitSpigot#safe?
111
+ 0.11% 0.11% 2 2 0 8635 Fixnum#==
112
+ ----------------------------------------------------------------------------------------------------
113
+ 0 0 0 42 Transformation#extract
114
+ 0.00% 0.00% 0 0 0 42 Fixnum#/
115
+ ----------------------------------------------------------------------------------------------------
116
+ 0 0 0 200 Object#compute_pidigits
117
+ 0.00% 0.00% 0 0 0 200 Fixnum#>=
118
+ ----------------------------------------------------------------------------------------------------
119
+ 0 0 0 1 Object#compute_pidigits
120
+ 0.00% 0.00% 0 0 0 1 PiDigitSpigot#initialize
121
+ 0 0 0 3 Transformation#initialize
122
+ ----------------------------------------------------------------------------------------------------
123
+ 0 0 0 1 Object#compute_pidigits
124
+ 0.00% 0.00% 0 0 0 1 Kernel#Integer
125
+ ----------------------------------------------------------------------------------------------------
@@ -0,0 +1,92 @@
1
+ # The Great Computer Language Shootout
2
+ # http://shootout.alioth.debian.org/
3
+ #
4
+ # contributed by Gabriele Renzi
5
+
6
+ class PiDigitSpigot
7
+
8
+ def initialize()
9
+ @z = Transformation.new 1,0,0,1
10
+ @x = Transformation.new 0,0,0,0
11
+ @inverse = Transformation.new 0,0,0,0
12
+ end
13
+
14
+ def next!
15
+ @y = @z.extract(3)
16
+ if safe? @y
17
+ @z = produce(@y)
18
+ @y
19
+ else
20
+ @z = consume @x.next!()
21
+ next!()
22
+ end
23
+ end
24
+
25
+ def safe?(digit)
26
+ digit == @z.extract(4)
27
+ end
28
+
29
+ def produce(i)
30
+ @inverse.qrst(10,-10*i,0,1).compose(@z)
31
+ end
32
+
33
+ def consume(a)
34
+ @z.compose(a)
35
+ end
36
+ end
37
+
38
+
39
+ class Transformation
40
+ attr_reader :q, :r, :s, :t
41
+ def initialize (q, r, s, t)
42
+ @q,@r,@s,@t,@k = q,r,s,t,0
43
+ end
44
+
45
+ def next!()
46
+ @q = @k = @k + 1
47
+ @r = 4 * @k + 2
48
+ @s = 0
49
+ @t = 2 * @k + 1
50
+ self
51
+ end
52
+
53
+ def extract(j)
54
+ (@q * j + @r) / (@s * j + @t)
55
+ end
56
+
57
+ def compose(a)
58
+ self.class.new( @q * a.q,
59
+ @q * a.r + r * a.t,
60
+ @s * a.q + t * a.s,
61
+ @s * a.r + t * a.t
62
+ )
63
+ end
64
+
65
+ def qrst *args
66
+ initialize *args
67
+ self
68
+ end
69
+
70
+
71
+ end
72
+
73
+ WIDTH = 10
74
+
75
+ def compute_pidigits(count)
76
+ n = Integer(count)
77
+ j = 0
78
+
79
+ digits = PiDigitSpigot.new
80
+
81
+ while n > 0
82
+ if n >= WIDTH
83
+ WIDTH.times { digits.next! }
84
+ j += WIDTH
85
+ else
86
+ n.times {print digits.next!}
87
+ (WIDTH-n).times { " "}
88
+ j += n
89
+ end
90
+ n -= WIDTH
91
+ end
92
+ end
@@ -0,0 +1,28 @@
1
+
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require 'jruby-prof'
4
+
5
+ require File.dirname(__FILE__) + "/pidigits"
6
+
7
+ compute_pidigits(2000)
8
+ compute_pidigits(2000)
9
+ compute_pidigits(2000)
10
+ compute_pidigits(2000)
11
+
12
+ s = Time.now
13
+ compute_pidigits(2000)
14
+ puts "took #{Time.now - s}s without tracing"
15
+
16
+ s = Time.now
17
+ JRubyProf.start
18
+ compute_pidigits(2000)
19
+ result = JRubyProf.stop
20
+
21
+ puts "took #{Time.now - s}s with tracing"
22
+
23
+ JRubyProf.print_flat_text(result, "example/flat.txt")
24
+ JRubyProf.print_graph_text(result, "example/graph.txt")
25
+ JRubyProf.print_graph_html(result, "example/graph.html")
26
+ JRubyProf.print_call_tree(result, "example/call_tree.txt")
27
+ JRubyProf.print_tree_html(result, "example/call_tree.html")
28
+
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'jruby-prof'
3
+
4
+ class Thing
5
+ def self.foo(a, b)
6
+ a + b
7
+ end
8
+ end
9
+
10
+ class Thing2
11
+ def self.bar(a, b)
12
+ a * b
13
+ end
14
+ end
15
+
16
+ result = JRubyProf.profile do
17
+ Thread.new do
18
+ 100.times {
19
+ Thing.foo(1, 2)
20
+ }
21
+ end
22
+ 100.times { Thing2.bar(1, 2) }
23
+ end
24
+
25
+ JRubyProf.print_flat_text(result, "flat.txt")
26
+ JRubyProf.print_graph_text(result, "graph.txt")
27
+ JRubyProf.print_graph_html(result, "graph.html")
28
+ JRubyProf.print_call_tree(result, "call_tree.txt")
29
+ JRubyProf.print_tree_html(result, "call_tree.html")
@@ -0,0 +1,28 @@
1
+ require 'java'
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require 'jruby-prof'
4
+
5
+ class Thing
6
+ def self.foo(a, b)
7
+ begin
8
+ Thing2.bar(a, b)
9
+ rescue
10
+ end
11
+ end
12
+ end
13
+
14
+ class Thing2
15
+ def self.bar(a, b)
16
+ raise "foo"
17
+ end
18
+ end
19
+
20
+ result = JRubyProf.profile do
21
+ 1.times { Thing.foo(1, 2) }
22
+ end
23
+
24
+ JRubyProf.print_flat_text(result, "flat.txt")
25
+ JRubyProf.print_graph_text(result, "graph.txt")
26
+ JRubyProf.print_graph_html(result, "graph.html")
27
+ JRubyProf.print_call_tree(result, "call_tree.txt")
28
+ JRubyProf.print_tree_html(result, "call_tree.html")
@@ -0,0 +1,43 @@
1
+
2
+ #$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ #require 'jruby-prof'
4
+
5
+ def empty_method
6
+ end
7
+
8
+ #puts "method overhead"
9
+ #
10
+ TIMES = 1000
11
+ #
12
+ #s = Time.now
13
+ #0.upto(TIMES) { empty_method }
14
+ #puts "#{TIMES} empty method calls took #{Time.now - s}s without tracing"
15
+ #
16
+ #JRubyProf.start
17
+ #s = Time.now
18
+ #0.upto(TIMES) { empty_method }
19
+ #JRubyProf.stop
20
+ #puts "#{TIMES} empty method calls took #{Time.now - s}s with tracing"
21
+
22
+
23
+ def fib(n)
24
+ a, b = 0, 1
25
+ n.times { a, b = b, a + b }
26
+ b
27
+ end
28
+
29
+ def test_fib
30
+ 0.upto(TIMES) { fib(5000) }
31
+ end
32
+
33
+ test_fib
34
+
35
+ s = Time.now
36
+ test_fib
37
+ puts "fib took #{Time.now - s}s without tracing"
38
+
39
+ JRubyProf.start
40
+ s = Time.now
41
+ test_fib
42
+ JRubyProf.stop
43
+ puts "fib took #{Time.now - s}s with tracing"
@@ -0,0 +1,66 @@
1
+
2
+ require 'java'
3
+ require 'erb'
4
+
5
+ require File.dirname(__FILE__) + "/jruby-prof.jar"
6
+
7
+ import org.jruby.prof.JRubyProf
8
+
9
+ require 'jruby-prof/abstract_printer'
10
+ require 'jruby-prof/simple_tree_printer'
11
+ require 'jruby-prof/flat_text_printer'
12
+ require 'jruby-prof/graph_text_printer'
13
+ require 'jruby-prof/graph_html_printer'
14
+ require 'jruby-prof/invocation_set'
15
+ require 'jruby-prof/method'
16
+ require 'jruby-prof/tree_html_printer'
17
+
18
+ require 'jruby-prof/profile_invocation'
19
+
20
+ class JRubyProf
21
+
22
+ def self.start
23
+ raise RuntimeError, "JRubyProf already running" if running?
24
+ start_tracing
25
+ end
26
+
27
+ def self.stop
28
+ stop_tracing
29
+ end
30
+
31
+ def self.running?
32
+ self.is_running
33
+ end
34
+
35
+ def self.profile
36
+ raise ArgumentError, "profile requires a block" unless block_given?
37
+ start
38
+ yield
39
+ stop
40
+ end
41
+
42
+ def self.print_call_tree(result, filename)
43
+ printer = SimpleTreePrinter.new(ThreadSet.new(result.values.to_a, JRubyProf.lastTracingDuration))
44
+ printer.print_to_file(filename)
45
+ end
46
+
47
+ def self.print_tree_html(result, filename)
48
+ printer = TreeHtmlPrinter.new(ThreadSet.new(result.values.to_a, JRubyProf.lastTracingDuration))
49
+ printer.print_to_file(filename)
50
+ end
51
+
52
+ def self.print_flat_text(result, filename)
53
+ printer = FlatTextPrinter.new(ThreadSet.new(result.values.to_a, JRubyProf.lastTracingDuration))
54
+ printer.print_to_file(filename)
55
+ end
56
+
57
+ def self.print_graph_text(result, filename)
58
+ printer = GraphTextPrinter.new(ThreadSet.new(result.values.to_a, JRubyProf.lastTracingDuration))
59
+ printer.print_to_file(filename)
60
+ end
61
+
62
+ def self.print_graph_html(result, filename)
63
+ printer = GraphHtmlPrinter.new(ThreadSet.new(result.values.to_a, JRubyProf.lastTracingDuration))
64
+ printer.print_to_file(filename)
65
+ end
66
+ end
@@ -0,0 +1,21 @@
1
+
2
+ class JRubyProf
3
+ class AbstractPrinter
4
+ attr_reader :thread_set
5
+
6
+ def initialize(thread_set, options={})
7
+ @thread_set = thread_set
8
+ @options = options
9
+ end
10
+
11
+ def print_to_file(filename)
12
+ puts "Dumping trace to #{File.expand_path(filename)}"
13
+ File.open(filename, "w") do |f|
14
+ print_on(f)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+
@@ -0,0 +1,35 @@
1
+
2
+ class JRubyProf
3
+ class FlatTextPrinter < AbstractPrinter
4
+ TABLE_HEADER = " %self cumulative total self children calls self/call total/call 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
+ total_duration = 0
14
+ rows = methods.map do |method|
15
+ total = method.duration
16
+ children = method.childrens_duration
17
+ self_ = total - children
18
+ total_duration += self_ unless self_ < 0
19
+ next if method.name == "#"
20
+ [total, children, self_, method.count, method.name]
21
+ end
22
+ cumulative = 0
23
+ rows = rows.compact.sort_by {|r| r[2]}.reverse
24
+ rows.each do |row|
25
+ total, children, self_, count, name = *row
26
+ cumulative += self_
27
+ self_pc = (self_.to_f/total_duration)*100
28
+ self_per_call = self_.to_f/count
29
+ total_per_call = total.to_f/count
30
+ output.puts "#{("%2.2f" % self_pc).rjust(6)} #{cumulative.to_s.rjust(11)} #{total.to_s.rjust(8)} #{self_.to_s.rjust(7)} #{children.to_s.rjust(8)} #{count.to_s.rjust(7)} #{("%2.2f" % self_per_call).to_s.rjust(9)} #{("%2.2f" % total_per_call).to_s.rjust(10)} #{name}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end