ruby-prof 0.13.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +579 -371
  3. data/LICENSE +24 -23
  4. data/README.rdoc +5 -433
  5. data/Rakefile +98 -110
  6. data/bin/ruby-prof +328 -329
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +16 -59
  9. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  10. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  11. data/ext/ruby_prof/rp_allocation.c +287 -0
  12. data/ext/ruby_prof/rp_allocation.h +31 -0
  13. data/ext/ruby_prof/rp_call_tree.c +369 -0
  14. data/ext/ruby_prof/rp_call_tree.h +43 -0
  15. data/ext/ruby_prof/rp_call_trees.c +288 -0
  16. data/ext/ruby_prof/rp_call_trees.h +28 -0
  17. data/ext/ruby_prof/rp_measure_allocations.c +50 -65
  18. data/ext/ruby_prof/rp_measure_memory.c +42 -73
  19. data/ext/ruby_prof/rp_measure_process_time.c +65 -71
  20. data/ext/ruby_prof/rp_measure_wall_time.c +64 -42
  21. data/ext/ruby_prof/rp_measurement.c +237 -0
  22. data/ext/ruby_prof/rp_measurement.h +50 -0
  23. data/ext/ruby_prof/rp_method.c +491 -420
  24. data/ext/ruby_prof/rp_method.h +62 -57
  25. data/ext/ruby_prof/rp_profile.c +908 -0
  26. data/ext/ruby_prof/rp_profile.h +35 -0
  27. data/ext/ruby_prof/rp_stack.c +212 -128
  28. data/ext/ruby_prof/rp_stack.h +53 -51
  29. data/ext/ruby_prof/rp_thread.c +362 -268
  30. data/ext/ruby_prof/rp_thread.h +39 -27
  31. data/ext/ruby_prof/ruby_prof.c +52 -695
  32. data/ext/ruby_prof/ruby_prof.h +26 -55
  33. data/ext/ruby_prof/vc/ruby_prof.sln +28 -21
  34. data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +56 -8
  35. data/lib/ruby-prof.rb +52 -67
  36. data/lib/ruby-prof/assets/call_stack_printer.html.erb +710 -0
  37. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  38. data/lib/ruby-prof/assets/graph_printer.html.erb +355 -0
  39. data/lib/ruby-prof/call_tree.rb +57 -0
  40. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  41. data/lib/ruby-prof/compatibility.rb +99 -169
  42. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  43. data/lib/ruby-prof/measurement.rb +17 -0
  44. data/lib/ruby-prof/method_info.rb +78 -131
  45. data/lib/ruby-prof/printers/abstract_printer.rb +137 -85
  46. data/lib/ruby-prof/printers/call_info_printer.rb +53 -41
  47. data/lib/ruby-prof/printers/call_stack_printer.rb +180 -773
  48. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -92
  49. data/lib/ruby-prof/printers/dot_printer.rb +132 -132
  50. data/lib/ruby-prof/printers/flat_printer.rb +53 -69
  51. data/lib/ruby-prof/printers/graph_html_printer.rb +63 -255
  52. data/lib/ruby-prof/printers/graph_printer.rb +113 -116
  53. data/lib/ruby-prof/printers/multi_printer.rb +127 -56
  54. data/lib/ruby-prof/profile.rb +37 -77
  55. data/lib/ruby-prof/rack.rb +62 -15
  56. data/lib/ruby-prof/task.rb +147 -147
  57. data/lib/ruby-prof/thread.rb +10 -12
  58. data/lib/ruby-prof/version.rb +3 -0
  59. data/lib/unprof.rb +10 -10
  60. data/ruby-prof.gemspec +65 -61
  61. data/test/abstract_printer_test.rb +26 -0
  62. data/test/alias_test.rb +126 -0
  63. data/test/basic_test.rb +43 -128
  64. data/test/call_tree_visitor_test.rb +32 -0
  65. data/test/call_trees_test.rb +66 -0
  66. data/test/duplicate_names_test.rb +32 -32
  67. data/test/dynamic_method_test.rb +53 -74
  68. data/test/enumerable_test.rb +21 -16
  69. data/test/exceptions_test.rb +24 -16
  70. data/test/exclude_methods_test.rb +151 -0
  71. data/test/exclude_threads_test.rb +53 -54
  72. data/test/fiber_test.rb +129 -65
  73. data/test/gc_test.rb +90 -0
  74. data/test/inverse_call_tree_test.rb +175 -0
  75. data/test/line_number_test.rb +158 -71
  76. data/test/marshal_test.rb +113 -0
  77. data/test/measure_allocations.rb +30 -0
  78. data/test/measure_allocations_test.rb +375 -25
  79. data/test/measure_allocations_trace_test.rb +375 -0
  80. data/test/measure_memory_trace_test.rb +1101 -0
  81. data/test/measure_process_time_test.rb +785 -62
  82. data/test/measure_times.rb +56 -0
  83. data/test/measure_wall_time_test.rb +434 -254
  84. data/test/multi_printer_test.rb +71 -82
  85. data/test/no_method_class_test.rb +15 -15
  86. data/test/pause_resume_test.rb +175 -166
  87. data/test/prime.rb +54 -54
  88. data/test/prime_script.rb +6 -0
  89. data/test/printer_call_stack_test.rb +27 -0
  90. data/test/printer_call_tree_test.rb +30 -0
  91. data/test/printer_flat_test.rb +99 -0
  92. data/test/printer_graph_html_test.rb +59 -0
  93. data/test/printer_graph_test.rb +40 -0
  94. data/test/printers_test.rb +141 -257
  95. data/test/printing_recursive_graph_test.rb +81 -0
  96. data/test/profile_test.rb +16 -0
  97. data/test/rack_test.rb +93 -0
  98. data/test/recursive_test.rb +206 -215
  99. data/test/singleton_test.rb +38 -38
  100. data/test/stack_printer_test.rb +64 -78
  101. data/test/start_stop_test.rb +109 -112
  102. data/test/test_helper.rb +13 -115
  103. data/test/thread_test.rb +144 -178
  104. data/test/unique_call_path_test.rb +120 -224
  105. data/test/yarv_test.rb +56 -0
  106. metadata +77 -133
  107. data/doc/LICENSE.html +0 -155
  108. data/doc/README_rdoc.html +0 -648
  109. data/doc/Rack.html +0 -167
  110. data/doc/Rack/RubyProf.html +0 -319
  111. data/doc/RubyProf.html +0 -1000
  112. data/doc/RubyProf/AbstractPrinter.html +0 -580
  113. data/doc/RubyProf/AggregateCallInfo.html +0 -570
  114. data/doc/RubyProf/CallInfo.html +0 -512
  115. data/doc/RubyProf/CallInfoPrinter.html +0 -190
  116. data/doc/RubyProf/CallInfoVisitor.html +0 -332
  117. data/doc/RubyProf/CallStackPrinter.html +0 -1600
  118. data/doc/RubyProf/CallTreePrinter.html +0 -413
  119. data/doc/RubyProf/Cmd.html +0 -669
  120. data/doc/RubyProf/DotPrinter.html +0 -312
  121. data/doc/RubyProf/FlatPrinter.html +0 -229
  122. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -267
  123. data/doc/RubyProf/GraphHtmlPrinter.html +0 -630
  124. data/doc/RubyProf/GraphPrinter.html +0 -209
  125. data/doc/RubyProf/MethodInfo.html +0 -713
  126. data/doc/RubyProf/MultiPrinter.html +0 -407
  127. data/doc/RubyProf/Profile.html +0 -821
  128. data/doc/RubyProf/ProfileTask.html +0 -532
  129. data/doc/RubyProf/Test.html +0 -578
  130. data/doc/RubyProf/Thread.html +0 -262
  131. data/doc/created.rid +0 -32
  132. data/doc/examples/flat_txt.html +0 -191
  133. data/doc/examples/graph_txt.html +0 -305
  134. data/doc/images/add.png +0 -0
  135. data/doc/images/brick.png +0 -0
  136. data/doc/images/brick_link.png +0 -0
  137. data/doc/images/bug.png +0 -0
  138. data/doc/images/bullet_black.png +0 -0
  139. data/doc/images/bullet_toggle_minus.png +0 -0
  140. data/doc/images/bullet_toggle_plus.png +0 -0
  141. data/doc/images/date.png +0 -0
  142. data/doc/images/delete.png +0 -0
  143. data/doc/images/find.png +0 -0
  144. data/doc/images/loadingAnimation.gif +0 -0
  145. data/doc/images/macFFBgHack.png +0 -0
  146. data/doc/images/package.png +0 -0
  147. data/doc/images/page_green.png +0 -0
  148. data/doc/images/page_white_text.png +0 -0
  149. data/doc/images/page_white_width.png +0 -0
  150. data/doc/images/plugin.png +0 -0
  151. data/doc/images/ruby.png +0 -0
  152. data/doc/images/tag_blue.png +0 -0
  153. data/doc/images/tag_green.png +0 -0
  154. data/doc/images/transparent.png +0 -0
  155. data/doc/images/wrench.png +0 -0
  156. data/doc/images/wrench_orange.png +0 -0
  157. data/doc/images/zoom.png +0 -0
  158. data/doc/index.html +0 -647
  159. data/doc/js/darkfish.js +0 -155
  160. data/doc/js/jquery.js +0 -18
  161. data/doc/js/navigation.js +0 -142
  162. data/doc/js/search.js +0 -94
  163. data/doc/js/search_index.js +0 -1
  164. data/doc/js/searcher.js +0 -228
  165. data/doc/rdoc.css +0 -543
  166. data/doc/table_of_contents.html +0 -462
  167. data/examples/empty.png +0 -0
  168. data/examples/flat.txt +0 -55
  169. data/examples/graph.dot +0 -106
  170. data/examples/graph.html +0 -823
  171. data/examples/graph.png +0 -0
  172. data/examples/graph.txt +0 -170
  173. data/examples/minus.png +0 -0
  174. data/examples/multi.flat.txt +0 -23
  175. data/examples/multi.graph.html +0 -906
  176. data/examples/multi.grind.dat +0 -194
  177. data/examples/multi.stack.html +0 -573
  178. data/examples/plus.png +0 -0
  179. data/examples/stack.html +0 -573
  180. data/ext/ruby_prof/rp_call_info.c +0 -407
  181. data/ext/ruby_prof/rp_call_info.h +0 -48
  182. data/ext/ruby_prof/rp_measure.c +0 -48
  183. data/ext/ruby_prof/rp_measure.h +0 -45
  184. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -112
  185. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -65
  186. data/ext/ruby_prof/rp_measure_gc_time.c +0 -57
  187. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -108
  188. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +0 -110
  189. data/ext/ruby_prof/version.h +0 -7
  190. data/lib/ruby-prof/aggregate_call_info.rb +0 -72
  191. data/lib/ruby-prof/call_info.rb +0 -89
  192. data/lib/ruby-prof/call_info_visitor.rb +0 -44
  193. data/lib/ruby-prof/images/empty.png +0 -0
  194. data/lib/ruby-prof/images/minus.png +0 -0
  195. data/lib/ruby-prof/images/plus.png +0 -0
  196. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -57
  197. data/lib/ruby-prof/test.rb +0 -150
  198. data/test/aggregate_test.rb +0 -136
  199. data/test/call_info_test.rb +0 -78
  200. data/test/call_info_visitor_test.rb +0 -31
  201. data/test/exec_test.rb +0 -14
  202. data/test/measure_cpu_time_test.rb +0 -220
  203. data/test/measure_gc_runs_test.rb +0 -32
  204. data/test/measure_gc_time_test.rb +0 -36
  205. data/test/measure_memory_test.rb +0 -31
  206. data/test/method_elimination_test.rb +0 -84
  207. data/test/module_test.rb +0 -45
  208. data/test/stack_test.rb +0 -138
  209. data/test/test_suite.rb +0 -37
@@ -1,55 +1,26 @@
1
- /* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Please see the LICENSE file for copyright and distribution information */
3
-
4
- #ifndef __RUBY_PROF_H__
5
- #define __RUBY_PROF_H__
6
-
7
- #include <ruby.h>
8
- #include <stdio.h>
9
-
10
- #if RUBY_VERSION == 186
11
- # error 1.8.6 is not supported. Please upgrade to 1.8.7 or 1.9.2 or higher.
12
- #endif
13
-
14
- #if RUBY_VERSION == 190
15
- # error 1.9.0 is not supported. Please upgrade to 1.9.2 or higher.
16
- #endif
17
-
18
- #if RUBY_VERSION == 191
19
- # error 1.9.1 is not supported. Please upgrade to 1.9.2 or higher.
20
- #endif
21
-
22
- #ifndef RUBY_VM
23
- #include <node.h>
24
- typedef rb_event_t rb_event_flag_t;
25
- #define rb_sourcefile() (node ? node->nd_file : 0)
26
- #define rb_sourceline() (node ? nd_line(node) : 0)
27
- #endif
28
-
29
- #include "version.h"
30
-
31
- #include "rp_measure.h"
32
- #include "rp_method.h"
33
- #include "rp_call_info.h"
34
- #include "rp_stack.h"
35
- #include "rp_thread.h"
36
-
37
- extern VALUE mProf;
38
- extern VALUE cProfile;
39
-
40
- void method_key(prof_method_key_t* key, VALUE klass, ID mid);
41
-
42
- typedef struct
43
- {
44
- VALUE running;
45
- VALUE paused;
46
- prof_measurer_t* measurer;
47
- VALUE threads;
48
- st_table* threads_tbl;
49
- st_table* exclude_threads_tbl;
50
- thread_data_t* last_thread_data;
51
- double measurement_at_pause_resume;
52
- } prof_profile_t;
53
-
54
-
55
- #endif //__RUBY_PROF_H__
1
+ /* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
+ Please see the LICENSE file for copyright and distribution information */
3
+
4
+ #ifndef __RUBY_PROF_H__
5
+ #define __RUBY_PROF_H__
6
+
7
+ #include <ruby.h>
8
+ #include <ruby/debug.h>
9
+ #include <stdio.h>
10
+ #include <stdbool.h>
11
+
12
+ #ifndef rb_st_lookup
13
+ #define rb_st_foreach st_foreach
14
+ #define rb_st_free_table st_free_table
15
+ #define rb_st_init_numtable st_init_numtable
16
+ #define rb_st_insert st_insert
17
+ #define rb_st_lookup st_lookup
18
+ #endif
19
+
20
+
21
+ extern VALUE mProf;
22
+
23
+ // This method is not exposed in Ruby header files - at least not as of Ruby 2.6.3 :(
24
+ extern size_t rb_obj_memsize_of(VALUE);
25
+
26
+ #endif //__RUBY_PROF_H__
@@ -1,32 +1,39 @@
1
1
  
2
- Microsoft Visual Studio Solution File, Format Version 11.00
3
- # Visual Studio 2010
4
- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof_18", "ruby_prof_18.vcxproj", "{7789FC23-D053-4733-9ED1-D6CE099E1237}"
5
- EndProject
6
- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof_19", "ruby_prof_19.vcxproj", "{5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}"
7
- EndProject
8
- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof_20", "ruby_prof_20.vcxproj", "{6B4978F4-3B5F-4D38-81A8-069EC28CC069}"
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio Version 16
4
+ VisualStudioVersion = 16.0.28803.452
5
+ MinimumVisualStudioVersion = 10.0.40219.1
6
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof", "ruby_prof.vcxproj", "{6B4978F4-3B5F-4D38-81A8-069EC28CC069}"
9
7
  EndProject
10
8
  Global
11
9
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
12
- Debug|Win32 = Debug|Win32
13
- Release|Win32 = Release|Win32
10
+ Debug|ARM = Debug|ARM
11
+ Debug|ARM64 = Debug|ARM64
12
+ Debug|x64 = Debug|x64
13
+ Debug|x86 = Debug|x86
14
+ Release|ARM = Release|ARM
15
+ Release|ARM64 = Release|ARM64
16
+ Release|x64 = Release|x64
17
+ Release|x86 = Release|x86
14
18
  EndGlobalSection
15
19
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
16
- {7789FC23-D053-4733-9ED1-D6CE099E1237}.Debug|Win32.ActiveCfg = Debug|Win32
17
- {7789FC23-D053-4733-9ED1-D6CE099E1237}.Debug|Win32.Build.0 = Debug|Win32
18
- {7789FC23-D053-4733-9ED1-D6CE099E1237}.Release|Win32.ActiveCfg = Release|Win32
19
- {7789FC23-D053-4733-9ED1-D6CE099E1237}.Release|Win32.Build.0 = Release|Win32
20
- {5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}.Debug|Win32.ActiveCfg = Debug|Win32
21
- {5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}.Debug|Win32.Build.0 = Debug|Win32
22
- {5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}.Release|Win32.ActiveCfg = Release|Win32
23
- {5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}.Release|Win32.Build.0 = Release|Win32
24
- {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|Win32.ActiveCfg = Debug|Win32
25
- {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|Win32.Build.0 = Debug|Win32
26
- {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|Win32.ActiveCfg = Release|Win32
27
- {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|Win32.Build.0 = Release|Win32
20
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM.ActiveCfg = Debug|Win32
21
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM64.ActiveCfg = Debug|Win32
22
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.ActiveCfg = Debug|x64
23
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.Build.0 = Debug|x64
24
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.ActiveCfg = Debug|Win32
25
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.Build.0 = Debug|Win32
26
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM.ActiveCfg = Release|Win32
27
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM64.ActiveCfg = Release|Win32
28
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.ActiveCfg = Release|x64
29
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.Build.0 = Release|x64
30
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x86.ActiveCfg = Release|Win32
31
+ {6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x86.Build.0 = Release|Win32
28
32
  EndGlobalSection
29
33
  GlobalSection(SolutionProperties) = preSolution
30
34
  HideSolutionNode = FALSE
31
35
  EndGlobalSection
36
+ GlobalSection(ExtensibilityGlobals) = postSolution
37
+ SolutionGuid = {9E7746F2-2467-4738-9746-4472B5CBF1DA}
38
+ EndGlobalSection
32
39
  EndGlobal
@@ -5,15 +5,24 @@
5
5
  <Configuration>Debug</Configuration>
6
6
  <Platform>Win32</Platform>
7
7
  </ProjectConfiguration>
8
+ <ProjectConfiguration Include="Debug|x64">
9
+ <Configuration>Debug</Configuration>
10
+ <Platform>x64</Platform>
11
+ </ProjectConfiguration>
8
12
  <ProjectConfiguration Include="Release|Win32">
9
13
  <Configuration>Release</Configuration>
10
14
  <Platform>Win32</Platform>
11
15
  </ProjectConfiguration>
16
+ <ProjectConfiguration Include="Release|x64">
17
+ <Configuration>Release</Configuration>
18
+ <Platform>x64</Platform>
19
+ </ProjectConfiguration>
12
20
  </ItemGroup>
13
21
  <PropertyGroup Label="Globals">
14
22
  <ProjectGuid>{6B4978F4-3B5F-4D38-81A8-069EC28CC069}</ProjectGuid>
15
23
  <Keyword>Win32Proj</Keyword>
16
24
  <RootNamespace>ruby_prof</RootNamespace>
25
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
17
26
  </PropertyGroup>
18
27
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19
28
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -27,6 +36,13 @@
27
36
  <WholeProgramOptimization>true</WholeProgramOptimization>
28
37
  <CharacterSet>Unicode</CharacterSet>
29
38
  </PropertyGroup>
39
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
40
+ <PlatformToolset>v142</PlatformToolset>
41
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
42
+ </PropertyGroup>
43
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
44
+ <PlatformToolset>v142</PlatformToolset>
45
+ </PropertyGroup>
30
46
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
31
47
  <ImportGroup Label="ExtensionSettings">
32
48
  </ImportGroup>
@@ -46,6 +62,10 @@
46
62
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
47
63
  <LinkIncremental>false</LinkIncremental>
48
64
  </PropertyGroup>
65
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66
+ <TargetExt>.so</TargetExt>
67
+ <OutDir>..\..\..\lib\</OutDir>
68
+ </PropertyGroup>
49
69
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
50
70
  <ClCompile>
51
71
  <PrecompiledHeader>
@@ -80,26 +100,54 @@
80
100
  <OptimizeReferences>true</OptimizeReferences>
81
101
  </Link>
82
102
  </ItemDefinitionGroup>
103
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
104
+ <ClCompile>
105
+ <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
106
+ <Optimization>Disabled</Optimization>
107
+ <PreprocessorDefinitions>HAVE_RB_TRACEARG_CALLEE_ID;%(PreprocessorDefinitions)</PreprocessorDefinitions>
108
+ <WarningLevel>Level3</WarningLevel>
109
+ </ClCompile>
110
+ <Link>
111
+ <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.2vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
112
+ <AdditionalDependencies>x64-vcruntime140-ruby270.lib;%(AdditionalDependencies)</AdditionalDependencies>
113
+ <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
114
+ <SubSystem>Console</SubSystem>
115
+ </Link>
116
+ </ItemDefinitionGroup>
117
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
118
+ <ClCompile>
119
+ <AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
120
+ </ClCompile>
121
+ <Link>
122
+ <AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.1vc\lib</AdditionalLibraryDirectories>
123
+ <AdditionalDependencies>x64-vcruntime140-ruby270.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
124
+ <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
125
+ </Link>
126
+ </ItemDefinitionGroup>
83
127
  <ItemGroup>
84
- <ClInclude Include="..\rp_call_info.h" />
85
- <ClInclude Include="..\rp_measure.h" />
128
+ <ClInclude Include="..\rp_aggregate_call_tree.h" />
129
+ <ClInclude Include="..\rp_allocation.h" />
130
+ <ClInclude Include="..\rp_call_tree.h" />
131
+ <ClInclude Include="..\rp_call_trees.h" />
132
+ <ClInclude Include="..\rp_measurement.h" />
86
133
  <ClInclude Include="..\rp_method.h" />
134
+ <ClInclude Include="..\rp_profile.h" />
87
135
  <ClInclude Include="..\rp_stack.h" />
88
136
  <ClInclude Include="..\rp_thread.h" />
89
137
  <ClInclude Include="..\ruby_prof.h" />
90
- <ClInclude Include="..\version.h" />
91
138
  </ItemGroup>
92
139
  <ItemGroup>
93
- <ClCompile Include="..\rp_call_info.c" />
94
- <ClCompile Include="..\rp_measure.c" />
140
+ <ClCompile Include="..\rp_aggregate_call_tree.c" />
141
+ <ClCompile Include="..\rp_allocation.c" />
142
+ <ClCompile Include="..\rp_call_tree.c" />
143
+ <ClCompile Include="..\rp_call_trees.c" />
144
+ <ClCompile Include="..\rp_measurement.c" />
95
145
  <ClCompile Include="..\rp_measure_allocations.c" />
96
- <ClCompile Include="..\rp_measure_cpu_time.c" />
97
- <ClCompile Include="..\rp_measure_gc_runs.c" />
98
- <ClCompile Include="..\rp_measure_gc_time.c" />
99
146
  <ClCompile Include="..\rp_measure_memory.c" />
100
147
  <ClCompile Include="..\rp_measure_process_time.c" />
101
148
  <ClCompile Include="..\rp_measure_wall_time.c" />
102
149
  <ClCompile Include="..\rp_method.c" />
150
+ <ClCompile Include="..\rp_profile.c" />
103
151
  <ClCompile Include="..\rp_stack.c" />
104
152
  <ClCompile Include="..\rp_thread.c" />
105
153
  <ClCompile Include="..\ruby_prof.c" />
@@ -1,67 +1,52 @@
1
- # encoding: utf-8
2
-
3
- # Load the C-based binding.
4
- begin
5
- RUBY_VERSION =~ /(\d+.\d+)/
6
- require "#{$1}/ruby_prof"
7
- rescue LoadError
8
- require "ruby_prof"
9
- end
10
-
11
- require 'ruby-prof/aggregate_call_info'
12
- require 'ruby-prof/call_info'
13
- require 'ruby-prof/call_info_visitor'
14
- require 'ruby-prof/compatibility'
15
- require 'ruby-prof/method_info'
16
- require 'ruby-prof/profile'
17
- require 'ruby-prof/rack'
18
- require 'ruby-prof/thread'
19
-
20
- require 'ruby-prof/printers/abstract_printer'
21
- require 'ruby-prof/printers/call_info_printer'
22
- require 'ruby-prof/printers/call_stack_printer'
23
- require 'ruby-prof/printers/call_tree_printer'
24
- require 'ruby-prof/printers/dot_printer'
25
- require 'ruby-prof/printers/flat_printer'
26
- require 'ruby-prof/printers/flat_printer_with_line_numbers'
27
- require 'ruby-prof/printers/graph_html_printer'
28
- require 'ruby-prof/printers/graph_printer'
29
- require 'ruby-prof/printers/multi_printer'
30
-
31
- module RubyProf
32
- # Checks if the user specified the clock mode via
33
- # the RUBY_PROF_MEASURE_MODE environment variable
34
- def self.figure_measure_mode
35
- case ENV["RUBY_PROF_MEASURE_MODE"]
36
- when "wall" || "wall_time"
37
- RubyProf.measure_mode = RubyProf::WALL_TIME
38
- when "cpu" || "cpu_time"
39
- if ENV.key?("RUBY_PROF_CPU_FREQUENCY")
40
- RubyProf.cpu_frequency = ENV["RUBY_PROF_CPU_FREQUENCY"].to_f
41
- else
42
- begin
43
- open("/proc/cpuinfo") do |f|
44
- f.each_line do |line|
45
- s = line.slice(/cpu MHz\s*:\s*(.*)/, 1)
46
- if s
47
- RubyProf.cpu_frequency = s.to_f * 1000000
48
- break
49
- end
50
- end
51
- end
52
- rescue Errno::ENOENT
53
- end
54
- end
55
- RubyProf.measure_mode = RubyProf::CPU_TIME
56
- when "allocations"
57
- RubyProf.measure_mode = RubyProf::ALLOCATIONS
58
- when "memory"
59
- RubyProf.measure_mode = RubyProf::MEMORY
60
- else
61
- # the default...
62
- RubyProf.measure_mode = RubyProf::PROCESS_TIME
63
- end
64
- end
65
- end
66
-
67
- RubyProf::figure_measure_mode
1
+ # encoding: utf-8
2
+ require 'rubygems/version'
3
+
4
+ # Load the C-based binding.
5
+ begin
6
+ version = Gem::Version.new(RUBY_VERSION)
7
+ require "#{version.segments[0..1].join('.')}/ruby_prof.so"
8
+ rescue LoadError
9
+ require "ruby_prof.so"
10
+ end
11
+
12
+ require 'ruby-prof/version'
13
+ require 'ruby-prof/call_tree'
14
+ require 'ruby-prof/compatibility'
15
+ require 'ruby-prof/measurement'
16
+ require 'ruby-prof/method_info'
17
+ require 'ruby-prof/profile'
18
+ require 'ruby-prof/rack'
19
+ require 'ruby-prof/thread'
20
+
21
+ module RubyProf
22
+ autoload :CallTreeVisitor, 'ruby-prof/call_tree_visitor'
23
+ autoload :AbstractPrinter, 'ruby-prof/printers/abstract_printer'
24
+ autoload :CallInfoPrinter, 'ruby-prof/printers/call_info_printer'
25
+ autoload :CallStackPrinter, 'ruby-prof/printers/call_stack_printer'
26
+ autoload :CallTreePrinter, 'ruby-prof/printers/call_tree_printer'
27
+ autoload :DotPrinter, 'ruby-prof/printers/dot_printer'
28
+ autoload :FlatPrinter, 'ruby-prof/printers/flat_printer'
29
+ autoload :GraphHtmlPrinter, 'ruby-prof/printers/graph_html_printer'
30
+ autoload :GraphPrinter, 'ruby-prof/printers/graph_printer'
31
+ autoload :MultiPrinter, 'ruby-prof/printers/multi_printer'
32
+
33
+ # :nodoc:
34
+ # Checks if the user specified the clock mode via
35
+ # the RUBY_PROF_MEASURE_MODE environment variable
36
+ def self.figure_measure_mode
37
+ case ENV["RUBY_PROF_MEASURE_MODE"]
38
+ when "wall", "wall_time"
39
+ RubyProf.measure_mode = RubyProf::WALL_TIME
40
+ when "allocations"
41
+ RubyProf.measure_mode = RubyProf::ALLOCATIONS
42
+ when "memory"
43
+ RubyProf.measure_mode = RubyProf::MEMORY
44
+ when "process", "process_time"
45
+ RubyProf.measure_mode = RubyProf::PROCESS_TIME
46
+ else
47
+ # the default is defined in the measure_mode reader
48
+ end
49
+ end
50
+ end
51
+
52
+ RubyProf::figure_measure_mode
@@ -0,0 +1,710 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
+ <title>ruby-prof call tree</title>
6
+ <style type="text/css">
7
+ body {
8
+ font-size: 70%;
9
+ padding: 0;
10
+ margin: 5px;
11
+ margin-right: 0px;
12
+ margin-left: 0px;
13
+ background: #ffffff;
14
+ }
15
+
16
+ ul {
17
+ margin-left: 0px;
18
+ margin-top: 0px;
19
+ margin-bottom: 0px;
20
+ padding-left: 0px;
21
+ list-style-type: none;
22
+ }
23
+
24
+ li {
25
+ margin-left: 11px;
26
+ padding: 0px;
27
+ white-space: nowrap;
28
+ border-top: 1px solid #cccccc;
29
+ border-left: 1px solid #cccccc;
30
+ border-bottom: none;
31
+ }
32
+
33
+ .thread {
34
+ margin-left: 11px;
35
+ background: #708090;
36
+ padding-top: 3px;
37
+ padding-left: 12px;
38
+ padding-bottom: 2px;
39
+ border-left: 1px solid #CCCCCC;
40
+ border-top: 1px solid #CCCCCC;
41
+ font-weight: bold;
42
+ }
43
+
44
+ .hidden {
45
+ display: none;
46
+ width: 0px;
47
+ height: 0px;
48
+ margin: 0px;
49
+ padding: 0px;
50
+ border-style: none;
51
+ }
52
+
53
+ .color01 {
54
+ background: #adbdeb
55
+ }
56
+
57
+ .color05 {
58
+ background: #9daddb
59
+ }
60
+
61
+ .color0 {
62
+ background: #8d9dcb
63
+ }
64
+
65
+ .color1 {
66
+ background: #89bccb
67
+ }
68
+
69
+ .color2 {
70
+ background: #56e3e7
71
+ }
72
+
73
+ .color3 {
74
+ background: #32cd70
75
+ }
76
+
77
+ .color4 {
78
+ background: #a3d53c
79
+ }
80
+
81
+ .color5 {
82
+ background: #c4cb34
83
+ }
84
+
85
+ .color6 {
86
+ background: #dcb66d
87
+ }
88
+
89
+ .color7 {
90
+ background: #cda59e
91
+ }
92
+
93
+ .color8 {
94
+ background: #be9d9c
95
+ }
96
+
97
+ .color9 {
98
+ background: #cf947a
99
+ }
100
+
101
+ #commands {
102
+ font-size: 10pt;
103
+ padding: 10px;
104
+ margin-left: 11px;
105
+ margin-bottom: 0px;
106
+ margin-top: 0px;
107
+ background: #708090;
108
+ border-top: 1px solid #cccccc;
109
+ border-left: 1px solid #cccccc;
110
+ border-bottom: none;
111
+ }
112
+
113
+ #titlebar {
114
+ font-size: 10pt;
115
+ padding: 10px;
116
+ margin-left: 11px;
117
+ margin-bottom: 0px;
118
+ margin-top: 10px;
119
+ background: #8090a0;
120
+ border-top: 1px solid #cccccc;
121
+ border-left: 1px solid #cccccc;
122
+ border-bottom: none;
123
+ }
124
+
125
+ #help {
126
+ font-size: 10pt;
127
+ padding: 10px;
128
+ margin-left: 11px;
129
+ margin-bottom: 0px;
130
+ margin-top: 0px;
131
+ background: #8090a0;
132
+ display: none;
133
+ border-top: 1px solid #cccccc;
134
+ border-left: 1px solid #cccccc;
135
+ border-bottom: none;
136
+ }
137
+
138
+ #sentinel {
139
+ height: 400px;
140
+ margin-left: 11px;
141
+ background: #8090a0;
142
+ border-top: 1px solid #cccccc;
143
+ border-left: 1px solid #cccccc;
144
+ border-bottom: none;
145
+ }
146
+
147
+ input {
148
+ margin-left: 10px;
149
+ }
150
+
151
+ .toggle {
152
+ background: url(data:image/png;base64,<%= base64_image %>) no-repeat left center;
153
+ float: left;
154
+ width: 9px;
155
+ height: 9px;
156
+ margin: 2px 1px 1px 1px;
157
+ }
158
+
159
+ .toggle.minus {
160
+ background-position: -9px 0;
161
+ }
162
+
163
+ .toggle.plus {
164
+ background-position: -18px 0;
165
+ }
166
+ </style>
167
+
168
+ <script type="text/javascript">
169
+ function rootNode()
170
+ {
171
+ return currentThread
172
+ }
173
+
174
+ function showUL(node, show)
175
+ {
176
+ Array.prototype.forEach.call(node.childNodes, function(child)
177
+ {
178
+ if (child.nodeName == 'LI')
179
+ toggle(child, show)
180
+ })
181
+ }
182
+
183
+ function findUlChild(li)
184
+ {
185
+ var ul = li.childNodes[2]
186
+ while (ul && ul.nodeName != "UL")
187
+ {
188
+ ul = ul.nextSibling
189
+ }
190
+ return ul
191
+ }
192
+
193
+ function isLeafNode(li)
194
+ {
195
+ var element = li.querySelector('a')
196
+ return element.classList.contains('empty')
197
+ }
198
+
199
+ function toggle(li, show)
200
+ {
201
+ if (isLeafNode(li))
202
+ return
203
+
204
+ var img = li.firstChild
205
+ img.className = 'toggle '
206
+ img.className += show ? 'minus' : 'plus'
207
+
208
+ var ul = findUlChild(li)
209
+ if (ul)
210
+ {
211
+ ul.style.display = show ? 'block' : 'none'
212
+ showUL(ul, true)
213
+ }
214
+ }
215
+
216
+ function toggleLI(li)
217
+ {
218
+ var img = li.firstChild
219
+ if (img.className.indexOf("minus") > -1)
220
+ toggle(li, false)
221
+ else
222
+ {
223
+ if (img.className.indexOf("plus") > -1)
224
+ toggle(li, true)
225
+ }
226
+ }
227
+
228
+ function aboveThreshold(text, threshold)
229
+ {
230
+ var match = text.match(/\d+[.,]\d+%/)
231
+ if (!match)
232
+ {
233
+ return true
234
+ }
235
+ else
236
+ {
237
+ var value = parseFloat(match[0].replace(/,/, '.'))
238
+ return value >= threshold
239
+ }
240
+ }
241
+
242
+ function setThresholdLI(li, threshold)
243
+ {
244
+ var a = li.querySelector('a')
245
+ var span = li.querySelector('span')
246
+ var ul = li.querySelector('ul')
247
+
248
+ var visible = aboveThreshold(span.textContent, threshold) ? 1 : 0
249
+
250
+ var count = 0
251
+ if (ul)
252
+ {
253
+ count = setThresholdUL(ul, threshold)
254
+ }
255
+
256
+ if (count > 0)
257
+ {
258
+ a.className = 'toggle minus'
259
+ }
260
+ else
261
+ {
262
+ a.className = 'toggle empty'
263
+ }
264
+
265
+ if (visible)
266
+ {
267
+ li.style.display = 'block'
268
+ } else
269
+ {
270
+ li.style.display = 'none'
271
+ }
272
+ return visible
273
+ }
274
+
275
+ function setThresholdUL(node, threshold)
276
+ {
277
+ var count = 0
278
+ Array.prototype.forEach.call(node.childNodes, function(child)
279
+ {
280
+ if (child.nodeName == 'LI')
281
+ count = count + setThresholdLI(child, threshold)
282
+ })
283
+
284
+ var visible = (count > 0) ? 1 : 0
285
+ if (visible)
286
+ {
287
+ node.style.display = 'block'
288
+ } else
289
+ {
290
+ node.style.display = 'none'
291
+ }
292
+ return visible
293
+ }
294
+
295
+ function toggleChildren(img, event)
296
+ {
297
+ event.cancelBubble = true
298
+ if (img.className.indexOf('empty') > -1)
299
+ return
300
+
301
+ var minus = (img.className.indexOf('minus') > -1)
302
+
303
+ if (minus)
304
+ {
305
+ img.className = 'toggle plus'
306
+ } else
307
+ img.className = 'toggle minus'
308
+
309
+ var li = img.parentNode
310
+ var ul = findUlChild(li)
311
+ if (ul)
312
+ {
313
+ if (minus)
314
+ ul.style.display = 'none'
315
+ else
316
+ ul.style.display = 'block'
317
+ }
318
+ if (minus)
319
+ moveSelectionIfNecessary(li)
320
+ }
321
+
322
+ function showChildren(li)
323
+ {
324
+ var img = li.firstChild
325
+ if (img.className.indexOf('empty') > -1)
326
+ return
327
+ img.className = 'toggle minus'
328
+
329
+ var ul = findUlChild(li)
330
+ if (ul)
331
+ {
332
+ ul.style.display = 'block'
333
+ }
334
+ }
335
+
336
+ function setThreshold()
337
+ {
338
+ var tv = document.getElementById("threshold").value
339
+ if (tv.match(/[0-9]+([.,][0-9]+)?/))
340
+ {
341
+ var f = parseFloat(tv.replace(/,/, '.'))
342
+ var threads = document.getElementsByName("thread")
343
+ var l = threads.length
344
+ for (var i = 0; i < l; i++)
345
+ {
346
+ setThresholdUL(threads[i], f)
347
+ }
348
+ var p = selectedNode
349
+ while (p && p.style.display == 'none')
350
+ p = p.parentNode.parentNode
351
+ if (p && p.nodeName == "LI")
352
+ selectNode(p)
353
+ } else
354
+ {
355
+ alert("Please specify a decimal number as threshold value!")
356
+ }
357
+ }
358
+
359
+ function expandAll(event)
360
+ {
361
+ toggleAll(event, true)
362
+ }
363
+
364
+ function collapseAll(event)
365
+ {
366
+ toggleAll(event, false)
367
+ selectNode(rootNode(), null)
368
+ }
369
+
370
+ function toggleAll(event, show)
371
+ {
372
+ event.cancelBubble = true
373
+ var threads = document.getElementsByName("thread")
374
+ var l = threads.length
375
+ for (var i = 0; i < l; i++)
376
+ {
377
+ showUL(threads[i], show)
378
+ }
379
+ }
380
+
381
+ function toggleHelp(node)
382
+ {
383
+ var help = document.getElementById("help")
384
+ if (node.value == "Show Help")
385
+ {
386
+ node.value = "Hide Help"
387
+ help.style.display = 'block'
388
+ } else
389
+ {
390
+ node.value = "Show Help"
391
+ help.style.display = 'none'
392
+ }
393
+ }
394
+
395
+ var selectedNode = null
396
+ var selectedColor = null
397
+ var selectedThread = null
398
+
399
+ function descendentOf(a, b)
400
+ {
401
+ while (a != b && b != null)
402
+ b = b.parentNode
403
+ return (a == b)
404
+ }
405
+
406
+ function moveSelectionIfNecessary(node)
407
+ {
408
+ if (descendentOf(node, selectedNode))
409
+ selectNode(node, null)
410
+ }
411
+
412
+ function selectNode(node, event)
413
+ {
414
+ if (event)
415
+ {
416
+ event.cancelBubble = true
417
+ thread = findThread(node)
418
+ selectThread(thread)
419
+ }
420
+ if (selectedNode)
421
+ {
422
+ selectedNode.style.background = selectedColor
423
+ }
424
+ selectedNode = node
425
+ selectedColor = node.style.background
426
+ selectedNode.style.background = "red"
427
+ selectedNode.scrollIntoView()
428
+ window.scrollBy(0, -400)
429
+ }
430
+
431
+ function moveUp()
432
+ {
433
+ move(selectedNode.previousSibling)
434
+ }
435
+
436
+ function moveDown()
437
+ {
438
+ move(selectedNode.nextSibling)
439
+ }
440
+
441
+ function move(p)
442
+ {
443
+ while (p && p.style.display == 'none')
444
+ p = p.nextSibling
445
+ if (p && p.nodeName == "LI")
446
+ {
447
+ selectNode(p, null)
448
+ }
449
+ }
450
+
451
+ function moveLeft()
452
+ {
453
+ var p = selectedNode.parentNode.parentNode
454
+ if (p && p.nodeName == "LI")
455
+ {
456
+ selectNode(p, null)
457
+ }
458
+ }
459
+
460
+ function moveRight()
461
+ {
462
+ if (!isLeafNode(selectedNode))
463
+ {
464
+ showChildren(selectedNode)
465
+ var ul = findUlChild(selectedNode)
466
+ if (ul)
467
+ {
468
+ selectNode(ul.firstChild, null)
469
+ }
470
+ }
471
+ }
472
+
473
+ function moveForward()
474
+ {
475
+ if (isLeafNode(selectedNode))
476
+ {
477
+ var p = selectedNode
478
+ while ((p.nextSibling == null || p.nextSibling.style.display == 'none') && p.nodeName == "LI")
479
+ {
480
+ p = p.parentNode.parentNode
481
+ }
482
+ if (p.nodeName == "LI")
483
+ selectNode(p.nextSibling, null)
484
+ } else
485
+ {
486
+ moveRight()
487
+ }
488
+ }
489
+
490
+ function isExpandedNode(li)
491
+ {
492
+ var img = li.firstChild
493
+ return (img.className.indexOf('minus') > -1)
494
+ }
495
+
496
+ function moveBackward()
497
+ {
498
+ var p = selectedNode
499
+ var q = p.previousSibling
500
+ while (q != null && q.style.display == 'none')
501
+ q = q.previousSibling
502
+ if (q == null)
503
+ {
504
+ p = p.parentNode.parentNode
505
+ } else
506
+ {
507
+ while (!isLeafNode(q) && isExpandedNode(q))
508
+ {
509
+ q = findUlChild(q).lastChild
510
+ while (q.style.display == 'none')
511
+ q = q.previousSibling
512
+ }
513
+ p = q
514
+ }
515
+ if (p.nodeName == "LI")
516
+ selectNode(p, null)
517
+ }
518
+
519
+ function moveHome()
520
+ {
521
+ selectNode(currentThread)
522
+ }
523
+
524
+ var currentThreadIndex = null
525
+
526
+ function findThread(node)
527
+ {
528
+ while (node && !node.parentNode.nodeName.match(/BODY|DIV/g))
529
+ {
530
+ node = node.parentNode
531
+ }
532
+ return node.firstChild
533
+ }
534
+
535
+ function selectThread(node)
536
+ {
537
+ var threads = document.getElementsByName("thread")
538
+ currentThread = node
539
+ for (var i = 0; i < threads.length; i++)
540
+ {
541
+ if (threads[i] == currentThread.parentNode)
542
+ currentThreadIndex = i
543
+ }
544
+ }
545
+
546
+ function nextThread()
547
+ {
548
+ var threads = document.getElementsByName("thread")
549
+ if (currentThreadIndex == threads.length - 1)
550
+ currentThreadIndex = 0
551
+ else
552
+ currentThreadIndex += 1
553
+ currentThread = threads[currentThreadIndex].firstChild
554
+ selectNode(currentThread, null)
555
+ }
556
+
557
+ function previousThread()
558
+ {
559
+ var threads = document.getElementsByName("thread")
560
+ if (currentThreadIndex == 0)
561
+ currentThreadIndex = threads.length - 1
562
+ else
563
+ currentThreadIndex -= 1
564
+ currentThread = threads[currentThreadIndex].firstChild
565
+ selectNode(currentThread, null)
566
+ }
567
+
568
+ function switchThread(node, event)
569
+ {
570
+ event.cancelBubble = true
571
+ selectThread(node.nextSibling.firstChild)
572
+ selectNode(currentThread, null)
573
+ }
574
+
575
+ function handleKeyEvent(event)
576
+ {
577
+ var code = event.charCode ? event.charCode : event.keyCode
578
+ var str = String.fromCharCode(code)
579
+ switch (str)
580
+ {
581
+ case "a":
582
+ moveLeft()
583
+ break
584
+ case "s":
585
+ moveDown()
586
+ break
587
+ case "d":
588
+ moveRight()
589
+ break
590
+ case "w":
591
+ moveUp()
592
+ break
593
+ case "f":
594
+ moveForward()
595
+ break
596
+ case "b":
597
+ moveBackward()
598
+ break
599
+ case "x":
600
+ toggleChildren(selectedNode.firstChild, event)
601
+ break
602
+ case "*":
603
+ toggleLI(selectedNode)
604
+ break
605
+ case "n":
606
+ nextThread()
607
+ break
608
+ case "h":
609
+ moveHome()
610
+ break
611
+ case "p":
612
+ previousThread()
613
+ break
614
+ }
615
+ }
616
+
617
+ document.onkeypress = function (event)
618
+ {
619
+ handleKeyEvent(event)
620
+ }
621
+
622
+ window.onload = function ()
623
+ {
624
+ var images = document.querySelectorAll(".toggle")
625
+ for (var i = 0; i < images.length; i++)
626
+ {
627
+ var img = images[i]
628
+ img.onclick = function (event)
629
+ {
630
+ toggleChildren(this, event)
631
+ return false
632
+ }
633
+ }
634
+ var divs = document.getElementsByTagName("div")
635
+ for (i = 0; i < divs.length; i++)
636
+ {
637
+ var div = divs[i]
638
+ if (div.className == "thread")
639
+ div.onclick = function (event)
640
+ {
641
+ switchThread(this, event)
642
+ }
643
+ }
644
+ var lis = document.getElementsByTagName("li")
645
+ for (var i = 0; i < lis.length; i++)
646
+ {
647
+ lis[i].onclick = function (event)
648
+ {
649
+ selectNode(this, event)
650
+ }
651
+ }
652
+
653
+ var threads = document.getElementsByName("thread")
654
+ currentThreadIndex = 0
655
+ currentThread = threads[0].querySelector('li')
656
+ selectNode(currentThread, null)
657
+ }
658
+ </script>
659
+
660
+ <% @overall_time = @result.threads.reduce(0) do |val, thread|
661
+ val += thread.total_time
662
+ end %>
663
+ </head>
664
+ <body>
665
+ <div style="display: inline-block;">
666
+ <div id="titlebar">
667
+ Call tree for application <strong><%= application %> <%= arguments %></strong><br/> Generated on <%= Time.now %>
668
+ with options <%= @options.inspect %><br/>
669
+ </div>
670
+ <div id="commands">
671
+ <span style="font-size: 11pt; font-weight: bold;">Threshold:</span>
672
+ <input value="1.0" size="3" id="threshold" type="text">
673
+ <input value="Apply" onclick="setThreshold();" type="submit">
674
+ <input value="Expand All" onclick="expandAll(event);" type="submit">
675
+ <input value="Collapse All" onclick="collapseAll(event);" type="submit">
676
+ <input value="Show Help" onclick="toggleHelp(this);" type="submit">
677
+ </div>
678
+ <ul style="display: none;" id="help">
679
+ <li>* indicates recursively called methods</li>
680
+ <li>Enter a decimal value <i>d</i> into the threshold field and click "Apply" to hide all nodes marked with time
681
+ values lower than <em>d</em>.
682
+ </li>
683
+ <li>Click on "Expand All" for full tree expansion.</li>
684
+ <li>Click on "Collapse All" to show only top level nodes.</li>
685
+ <li>Use a, s, d, w as in Quake or Urban Terror to navigate the tree.</li>
686
+ <li>Use f and b to navigate the tree in preorder forward and backwards.</li>
687
+ <li>Use x to toggle visibility of a subtree.</li>
688
+ <li>Use * to expand/collapse a whole subtree.</li>
689
+ <li>Use h to navigate to thread root.</li>
690
+ <li>Use n and p to navigate between threads.</li>
691
+ <li>Click on background to move focus to a subtree.</li>
692
+ </ul>
693
+
694
+ <% @result.threads.each do |thread| %>
695
+ <% thread_percent = 100 * (thread.total_time / @overall_time)
696
+ thread_info = "#{"%4.2f%%" % thread_percent} ~ #{@overall_time}" %>
697
+ <div class="thread">
698
+ <span>Thread: <%= thread.id %>, Fiber: <%= thread.fiber_id %> (<%= thread_info %>)</span>
699
+ <ul name="thread">
700
+ <% visited = Set.new
701
+ output = StringIO.new('')
702
+ print_stack(output, visited, thread.call_tree, thread.call_tree.total_time) %>
703
+ <%= output.string %>
704
+ </ul>
705
+ </div>
706
+ <% end %>
707
+ <div id="sentinel"></div>
708
+ </div>
709
+ </body>
710
+ </html>