ruby-prof 0.16.2 → 1.1.0

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 (203) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +532 -467
  3. data/LICENSE +24 -24
  4. data/README.rdoc +5 -454
  5. data/Rakefile +110 -113
  6. data/bin/ruby-prof +380 -340
  7. data/bin/ruby-prof-check-trace +45 -45
  8. data/ext/ruby_prof/extconf.rb +36 -64
  9. data/ext/ruby_prof/rp_allocation.c +279 -0
  10. data/ext/ruby_prof/rp_allocation.h +31 -0
  11. data/ext/ruby_prof/rp_call_info.c +271 -407
  12. data/ext/ruby_prof/rp_call_info.h +35 -48
  13. data/ext/ruby_prof/rp_measure_allocations.c +52 -76
  14. data/ext/ruby_prof/rp_measure_memory.c +42 -77
  15. data/ext/ruby_prof/rp_measure_process_time.c +67 -71
  16. data/ext/ruby_prof/rp_measure_wall_time.c +62 -45
  17. data/ext/ruby_prof/rp_measurement.c +230 -0
  18. data/ext/ruby_prof/rp_measurement.h +50 -0
  19. data/ext/ruby_prof/rp_method.c +630 -411
  20. data/ext/ruby_prof/rp_method.h +70 -52
  21. data/ext/ruby_prof/rp_profile.c +895 -0
  22. data/ext/ruby_prof/rp_profile.h +37 -0
  23. data/ext/ruby_prof/rp_stack.c +196 -128
  24. data/ext/ruby_prof/rp_stack.h +56 -51
  25. data/ext/ruby_prof/rp_thread.c +337 -273
  26. data/ext/ruby_prof/rp_thread.h +36 -27
  27. data/ext/ruby_prof/ruby_prof.c +48 -671
  28. data/ext/ruby_prof/ruby_prof.h +17 -56
  29. data/ext/ruby_prof/vc/ruby_prof.sln +20 -21
  30. data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +38 -5
  31. data/lib/ruby-prof.rb +52 -58
  32. data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
  33. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  34. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  35. data/lib/ruby-prof/call_info.rb +57 -126
  36. data/lib/ruby-prof/call_info_visitor.rb +38 -40
  37. data/lib/ruby-prof/compatibility.rb +109 -178
  38. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  39. data/lib/ruby-prof/measurement.rb +14 -0
  40. data/lib/ruby-prof/method_info.rb +90 -129
  41. data/lib/ruby-prof/printers/abstract_printer.rb +127 -85
  42. data/lib/ruby-prof/printers/call_info_printer.rb +51 -41
  43. data/lib/ruby-prof/printers/call_stack_printer.rb +182 -260
  44. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -130
  45. data/lib/ruby-prof/printers/dot_printer.rb +132 -132
  46. data/lib/ruby-prof/printers/flat_printer.rb +52 -70
  47. data/lib/ruby-prof/printers/graph_html_printer.rb +63 -244
  48. data/lib/ruby-prof/printers/graph_printer.rb +114 -116
  49. data/lib/ruby-prof/printers/multi_printer.rb +127 -58
  50. data/lib/ruby-prof/profile.rb +33 -55
  51. data/lib/ruby-prof/rack.rb +171 -95
  52. data/lib/ruby-prof/task.rb +147 -147
  53. data/lib/ruby-prof/thread.rb +35 -41
  54. data/lib/ruby-prof/version.rb +3 -3
  55. data/lib/unprof.rb +10 -10
  56. data/ruby-prof.gemspec +58 -57
  57. data/test/abstract_printer_test.rb +26 -0
  58. data/test/alias_test.rb +129 -0
  59. data/test/basic_test.rb +129 -128
  60. data/test/call_info_visitor_test.rb +31 -31
  61. data/test/duplicate_names_test.rb +32 -32
  62. data/test/dynamic_method_test.rb +53 -55
  63. data/test/enumerable_test.rb +21 -21
  64. data/test/exceptions_test.rb +24 -16
  65. data/test/exclude_methods_test.rb +146 -0
  66. data/test/exclude_threads_test.rb +53 -53
  67. data/test/fiber_test.rb +73 -79
  68. data/test/gc_test.rb +96 -0
  69. data/test/line_number_test.rb +161 -71
  70. data/test/marshal_test.rb +119 -0
  71. data/test/measure_allocations.rb +30 -0
  72. data/test/measure_allocations_test.rb +385 -26
  73. data/test/measure_allocations_trace_test.rb +385 -0
  74. data/test/measure_memory_trace_test.rb +756 -0
  75. data/test/measure_process_time_test.rb +849 -63
  76. data/test/measure_times.rb +54 -0
  77. data/test/measure_wall_time_test.rb +459 -255
  78. data/test/multi_printer_test.rb +71 -83
  79. data/test/no_method_class_test.rb +15 -15
  80. data/test/parser_timings.rb +24 -0
  81. data/test/pause_resume_test.rb +166 -166
  82. data/test/prime.rb +56 -54
  83. data/test/printer_call_stack_test.rb +28 -0
  84. data/test/printer_call_tree_test.rb +31 -0
  85. data/test/printer_flat_test.rb +68 -0
  86. data/test/printer_graph_html_test.rb +60 -0
  87. data/test/printer_graph_test.rb +41 -0
  88. data/test/printers_test.rb +141 -255
  89. data/test/printing_recursive_graph_test.rb +81 -127
  90. data/test/rack_test.rb +157 -93
  91. data/test/recursive_test.rb +210 -215
  92. data/test/singleton_test.rb +38 -38
  93. data/test/stack_printer_test.rb +64 -78
  94. data/test/start_stop_test.rb +109 -112
  95. data/test/test_helper.rb +24 -264
  96. data/test/thread_test.rb +144 -187
  97. data/test/unique_call_path_test.rb +190 -202
  98. data/test/yarv_test.rb +56 -55
  99. metadata +34 -114
  100. data/doc/LICENSE.html +0 -114
  101. data/doc/README_rdoc.html +0 -603
  102. data/doc/Rack.html +0 -95
  103. data/doc/Rack/RubyProf.html +0 -226
  104. data/doc/RubyProf.html +0 -962
  105. data/doc/RubyProf/AbstractPrinter.html +0 -546
  106. data/doc/RubyProf/AggregateCallInfo.html +0 -551
  107. data/doc/RubyProf/CallInfo.html +0 -639
  108. data/doc/RubyProf/CallInfoPrinter.html +0 -120
  109. data/doc/RubyProf/CallInfoVisitor.html +0 -198
  110. data/doc/RubyProf/CallStackPrinter.html +0 -1121
  111. data/doc/RubyProf/CallTreePrinter.html +0 -641
  112. data/doc/RubyProf/Cmd.html +0 -631
  113. data/doc/RubyProf/DotPrinter.html +0 -257
  114. data/doc/RubyProf/FlatPrinter.html +0 -163
  115. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -208
  116. data/doc/RubyProf/GraphHtmlPrinter.html +0 -552
  117. data/doc/RubyProf/GraphPrinter.html +0 -139
  118. data/doc/RubyProf/MethodInfo.html +0 -745
  119. data/doc/RubyProf/MultiPrinter.html +0 -360
  120. data/doc/RubyProf/Profile.html +0 -763
  121. data/doc/RubyProf/ProfileTask.html +0 -490
  122. data/doc/RubyProf/Thread.html +0 -310
  123. data/doc/created.rid +0 -31
  124. data/doc/css/fonts.css +0 -167
  125. data/doc/css/rdoc.css +0 -590
  126. data/doc/examples/flat_txt.html +0 -138
  127. data/doc/examples/graph_html.html +0 -909
  128. data/doc/examples/graph_txt.html +0 -247
  129. data/doc/fonts/Lato-Light.ttf +0 -0
  130. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  131. data/doc/fonts/Lato-Regular.ttf +0 -0
  132. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  133. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  134. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  135. data/doc/images/add.png +0 -0
  136. data/doc/images/arrow_up.png +0 -0
  137. data/doc/images/brick.png +0 -0
  138. data/doc/images/brick_link.png +0 -0
  139. data/doc/images/bug.png +0 -0
  140. data/doc/images/bullet_black.png +0 -0
  141. data/doc/images/bullet_toggle_minus.png +0 -0
  142. data/doc/images/bullet_toggle_plus.png +0 -0
  143. data/doc/images/date.png +0 -0
  144. data/doc/images/delete.png +0 -0
  145. data/doc/images/find.png +0 -0
  146. data/doc/images/loadingAnimation.gif +0 -0
  147. data/doc/images/macFFBgHack.png +0 -0
  148. data/doc/images/package.png +0 -0
  149. data/doc/images/page_green.png +0 -0
  150. data/doc/images/page_white_text.png +0 -0
  151. data/doc/images/page_white_width.png +0 -0
  152. data/doc/images/plugin.png +0 -0
  153. data/doc/images/ruby.png +0 -0
  154. data/doc/images/tag_blue.png +0 -0
  155. data/doc/images/tag_green.png +0 -0
  156. data/doc/images/transparent.png +0 -0
  157. data/doc/images/wrench.png +0 -0
  158. data/doc/images/wrench_orange.png +0 -0
  159. data/doc/images/zoom.png +0 -0
  160. data/doc/index.html +0 -626
  161. data/doc/js/darkfish.js +0 -161
  162. data/doc/js/jquery.js +0 -4
  163. data/doc/js/navigation.js +0 -142
  164. data/doc/js/navigation.js.gz +0 -0
  165. data/doc/js/search.js +0 -109
  166. data/doc/js/search_index.js +0 -1
  167. data/doc/js/search_index.js.gz +0 -0
  168. data/doc/js/searcher.js +0 -228
  169. data/doc/js/searcher.js.gz +0 -0
  170. data/doc/table_of_contents.html +0 -942
  171. data/examples/cachegrind.out.1 +0 -114
  172. data/examples/cachegrind.out.1.32313213 +0 -114
  173. data/examples/flat.txt +0 -50
  174. data/examples/graph.dot +0 -84
  175. data/examples/graph.html +0 -823
  176. data/examples/graph.txt +0 -139
  177. data/examples/multi.flat.txt +0 -23
  178. data/examples/multi.graph.html +0 -760
  179. data/examples/multi.grind.dat +0 -114
  180. data/examples/multi.stack.html +0 -547
  181. data/examples/stack.html +0 -547
  182. data/ext/ruby_prof/rp_measure.c +0 -40
  183. data/ext/ruby_prof/rp_measure.h +0 -45
  184. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
  185. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
  186. data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
  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/lib/ruby-prof/aggregate_call_info.rb +0 -76
  190. data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
  191. data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
  192. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -64
  193. data/test/aggregate_test.rb +0 -136
  194. data/test/block_test.rb +0 -74
  195. data/test/call_info_test.rb +0 -78
  196. data/test/issue137_test.rb +0 -63
  197. data/test/measure_cpu_time_test.rb +0 -213
  198. data/test/measure_gc_runs_test.rb +0 -32
  199. data/test/measure_gc_time_test.rb +0 -36
  200. data/test/measure_memory_test.rb +0 -33
  201. data/test/method_elimination_test.rb +0 -84
  202. data/test/module_test.rb +0 -45
  203. data/test/stack_test.rb +0 -138
@@ -1,110 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup Label="ProjectConfigurations">
4
- <ProjectConfiguration Include="Debug|Win32">
5
- <Configuration>Debug</Configuration>
6
- <Platform>Win32</Platform>
7
- </ProjectConfiguration>
8
- <ProjectConfiguration Include="Release|Win32">
9
- <Configuration>Release</Configuration>
10
- <Platform>Win32</Platform>
11
- </ProjectConfiguration>
12
- </ItemGroup>
13
- <PropertyGroup Label="Globals">
14
- <ProjectGuid>{5AF7F29A-B100-4D61-95DA-DB21D7C8C1B8}</ProjectGuid>
15
- <Keyword>Win32Proj</Keyword>
16
- <RootNamespace>ruby_prof</RootNamespace>
17
- </PropertyGroup>
18
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
20
- <ConfigurationType>DynamicLibrary</ConfigurationType>
21
- <UseDebugLibraries>true</UseDebugLibraries>
22
- <CharacterSet>Unicode</CharacterSet>
23
- </PropertyGroup>
24
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
25
- <ConfigurationType>DynamicLibrary</ConfigurationType>
26
- <UseDebugLibraries>false</UseDebugLibraries>
27
- <WholeProgramOptimization>true</WholeProgramOptimization>
28
- <CharacterSet>Unicode</CharacterSet>
29
- </PropertyGroup>
30
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
31
- <ImportGroup Label="ExtensionSettings">
32
- </ImportGroup>
33
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
34
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
35
- </ImportGroup>
36
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
37
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
38
- </ImportGroup>
39
- <PropertyGroup Label="UserMacros" />
40
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
41
- <LinkIncremental>true</LinkIncremental>
42
- <OutDir>..\..\..\lib\1.9</OutDir>
43
- <TargetExt>.so</TargetExt>
44
- <TargetName>ruby_prof</TargetName>
45
- </PropertyGroup>
46
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
47
- <LinkIncremental>false</LinkIncremental>
48
- </PropertyGroup>
49
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
50
- <ClCompile>
51
- <PrecompiledHeader>
52
- </PrecompiledHeader>
53
- <WarningLevel>Level3</WarningLevel>
54
- <Optimization>Disabled</Optimization>
55
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;RUBY_PROF_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
56
- <AdditionalIncludeDirectories>C:\MinGW\local\ruby193vc\include\ruby-1.9.1;C:\MinGW\local\ruby193vc\include\ruby-1.9.1\i386-mswin32_100;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
57
- </ClCompile>
58
- <Link>
59
- <SubSystem>Windows</SubSystem>
60
- <GenerateDebugInformation>true</GenerateDebugInformation>
61
- <AdditionalLibraryDirectories>C:\MinGW\local\ruby193vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
62
- <AdditionalDependencies>msvcr100-ruby191.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>
63
- <ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
64
- </Link>
65
- </ItemDefinitionGroup>
66
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
67
- <ClCompile>
68
- <WarningLevel>Level3</WarningLevel>
69
- <PrecompiledHeader>
70
- </PrecompiledHeader>
71
- <Optimization>MaxSpeed</Optimization>
72
- <FunctionLevelLinking>true</FunctionLevelLinking>
73
- <IntrinsicFunctions>true</IntrinsicFunctions>
74
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;RUBY_PROF_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
75
- </ClCompile>
76
- <Link>
77
- <SubSystem>Windows</SubSystem>
78
- <GenerateDebugInformation>true</GenerateDebugInformation>
79
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
80
- <OptimizeReferences>true</OptimizeReferences>
81
- </Link>
82
- </ItemDefinitionGroup>
83
- <ItemGroup>
84
- <ClInclude Include="..\rp_call_info.h" />
85
- <ClInclude Include="..\rp_measure.h" />
86
- <ClInclude Include="..\rp_method.h" />
87
- <ClInclude Include="..\rp_stack.h" />
88
- <ClInclude Include="..\rp_thread.h" />
89
- <ClInclude Include="..\ruby_prof.h" />
90
- <ClInclude Include="..\version.h" />
91
- </ItemGroup>
92
- <ItemGroup>
93
- <ClCompile Include="..\rp_call_info.c" />
94
- <ClCompile Include="..\rp_measure.c" />
95
- <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
- <ClCompile Include="..\rp_measure_memory.c" />
100
- <ClCompile Include="..\rp_measure_process_time.c" />
101
- <ClCompile Include="..\rp_measure_wall_time.c" />
102
- <ClCompile Include="..\rp_method.c" />
103
- <ClCompile Include="..\rp_stack.c" />
104
- <ClCompile Include="..\rp_thread.c" />
105
- <ClCompile Include="..\ruby_prof.c" />
106
- </ItemGroup>
107
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
108
- <ImportGroup Label="ExtensionTargets">
109
- </ImportGroup>
110
- </Project>
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module RubyProf
4
- class AggregateCallInfo
5
- attr_reader :call_infos, :method_info
6
-
7
- def initialize(call_infos, method_info)
8
- if call_infos.length == 0
9
- raise(ArgumentError, "Must specify at least one call info.")
10
- end
11
- @call_infos = call_infos
12
- @method_info = method_info
13
- end
14
-
15
- def target
16
- call_infos.first.target
17
- end
18
-
19
- def parent
20
- call_infos.first.parent
21
- end
22
-
23
- def line
24
- call_infos.first.line
25
- end
26
-
27
- def children
28
- call_infos.inject(Array.new) do |result, call_info|
29
- result.concat(call_info.children)
30
- end
31
- end
32
-
33
- def total_time
34
- aggregate_roots(:total_time)
35
- end
36
-
37
- def self_time
38
- aggregate_roots(:self_time)
39
- end
40
-
41
- def wait_time
42
- aggregate_roots(:wait_time)
43
- end
44
-
45
- def children_time
46
- aggregate_roots(:children_time)
47
- end
48
-
49
- def called
50
- aggregate_all(:called)
51
- end
52
-
53
- def to_s
54
- "#{call_infos.first.target.full_name}"
55
- end
56
-
57
- private
58
-
59
- # return all call_infos which are not (grand) children of any other node in the list of given call_infos
60
- def roots
61
- @roots ||= method_info.recursive? ? CallInfo.roots_of(call_infos) : call_infos
62
- end
63
-
64
- def aggregate_all(method_name)
65
- call_infos.inject(0) do |sum, call_info|
66
- sum + call_info.send(method_name)
67
- end
68
- end
69
-
70
- def aggregate_roots(method_name)
71
- roots.inject(0) do |sum, call_info|
72
- sum + call_info.send(method_name)
73
- end
74
- end
75
- end
76
- end
@@ -1,117 +0,0 @@
1
- <style type="text/css">
2
- <!--
3
- body {
4
- font-size:70%;
5
- padding:0;
6
- margin:5px;
7
- margin-right:0px;
8
- margin-left:0px;
9
- background: #ffffff;
10
- }
11
- ul {
12
- margin-left:0px;
13
- margin-top:0px;
14
- margin-bottom:0px;
15
- padding-left:0px;
16
- list-style-type:none;
17
- }
18
- li {
19
- margin-left:11px;
20
- padding:0px;
21
- white-space:nowrap;
22
- border-top:1px solid #cccccc;
23
- border-left:1px solid #cccccc;
24
- border-bottom:none;
25
- }
26
- .thread {
27
- margin-left:11px;
28
- background:#708090;
29
- padding-top:3px;
30
- padding-left:12px;
31
- padding-bottom:2px;
32
- border-left:1px solid #CCCCCC;
33
- border-top:1px solid #CCCCCC;
34
- font-weight:bold;
35
- }
36
- .hidden {
37
- display:none;
38
- width:0px;
39
- height:0px;
40
- margin:0px;
41
- padding:0px;
42
- border-style:none;
43
- }
44
- .color01 { background:#adbdeb }
45
- .color05 { background:#9daddb }
46
- .color0 { background:#8d9dcb }
47
- .color1 { background:#89bccb }
48
- .color2 { background:#56e3e7 }
49
- .color3 { background:#32cd70 }
50
- .color4 { background:#a3d53c }
51
- .color5 { background:#c4cb34 }
52
- .color6 { background:#dcb66d }
53
- .color7 { background:#cda59e }
54
- .color8 { background:#be9d9c }
55
- .color9 { background:#cf947a }
56
- #commands {
57
- font-size:10pt;
58
- padding:10px;
59
- margin-left:11px;
60
- margin-bottom:0px;
61
- margin-top:0px;
62
- background:#708090;
63
- border-top:1px solid #cccccc;
64
- border-left:1px solid #cccccc;
65
- border-bottom:none;
66
- }
67
- #titlebar {
68
- font-size:10pt;
69
- padding:10px;
70
- margin-left:11px;
71
- margin-bottom:0px;
72
- margin-top:10px;
73
- background:#8090a0;
74
- border-top:1px solid #cccccc;
75
- border-left:1px solid #cccccc;
76
- border-bottom:none;
77
- }
78
- #help {
79
- font-size:10pt;
80
- padding:10px;
81
- margin-left:11px;
82
- margin-bottom:0px;
83
- margin-top:0px;
84
- background:#8090a0;
85
- display:none;
86
- border-top:1px solid #cccccc;
87
- border-left:1px solid #cccccc;
88
- border-bottom:none;
89
- }
90
- #sentinel {
91
- height: 400px;
92
- margin-left:11px;
93
- background:#8090a0;
94
- border-top:1px solid #cccccc;
95
- border-left:1px solid #cccccc;
96
- border-bottom:none;
97
- }
98
- input { margin-left:10px; }
99
-
100
- .toggle {
101
- background: url(data:image/png;base64,%s) no-repeat left center;
102
- float:left;
103
- width:9px;
104
- height:9px;
105
- margin:2px 1px 1px 1px;
106
- }
107
-
108
- .toggle.minus {
109
- background-position: -9px 0;
110
- }
111
-
112
- .toggle.plus {
113
- background-position: -18px 0;
114
- }
115
-
116
- -->
117
- </style>
@@ -1,385 +0,0 @@
1
- <script type="text/javascript">
2
- /*
3
- Copyright (C) 2005,2009 Stefan Kaes
4
- skaes@railsexpress.de
5
- */
6
-
7
- function rootNode() {
8
- return currentThread;
9
- }
10
-
11
- function showUL(node, show) {
12
- var lis = node.childNodes;
13
- var l = lis.length;
14
- for (var i=0; i < l ; i++ ) {
15
- toggle(lis[i], show);
16
- }
17
- }
18
-
19
- function findUlChild(li){
20
- var ul = li.childNodes[2];
21
- while (ul && ul.nodeName != "UL") {
22
- ul = ul.nextSibling;
23
- }
24
- return ul;
25
- }
26
-
27
- function isLeafNode(li) {
28
- var img = li.firstChild;
29
- return (img.className.indexOf('empty') > -1);
30
- }
31
-
32
- function toggle(li, show) {
33
- if (isLeafNode(li))
34
- return;
35
-
36
- var img = li.firstChild;
37
- img.className = 'toggle ';
38
- img.className += show ? 'minus' : 'plus';
39
-
40
- var ul = findUlChild(li);
41
- if (ul) {
42
- ul.style.display = show ? 'block' : 'none';
43
- showUL(ul, true);
44
- }
45
- }
46
-
47
- function toggleLI(li) {
48
- var img = li.firstChild;
49
- if (img.className.indexOf("minus")>-1)
50
- toggle(li, false);
51
- else {
52
- if (img.className.indexOf("plus")>-1)
53
- toggle(li, true);
54
- }
55
- }
56
-
57
- function aboveThreshold(text, threshold) {
58
- var match = text.match(/\d+[.,]\d+/);
59
- return (match && parseFloat(match[0].replace(/,/, '.'))>=threshold);
60
- }
61
-
62
- function setThresholdLI(li, threshold) {
63
- var img = li.firstChild;
64
- var text = img.nextSibling.firstChild;
65
- var ul = findUlChild(li);
66
-
67
- var visible = aboveThreshold(text.nodeValue, threshold) ? 1 : 0;
68
-
69
- var count = 0;
70
- if (ul) {
71
- count = setThresholdUL(ul, threshold);
72
- }
73
- if (count>0) {
74
- img.className = 'toggle minus';
75
- }
76
- else {
77
- img.className = 'toggle empty';
78
- }
79
- if (visible) {
80
- li.style.display = 'block'
81
- }
82
- else {
83
- li.style.display = 'none'
84
- }
85
- return visible;
86
- }
87
-
88
- function setThresholdUL(node, threshold) {
89
- var lis = node.childNodes;
90
- var l = lis.length;
91
-
92
- var count = 0;
93
- for ( var i = 0; i < l ; i++ ) {
94
- count = count + setThresholdLI(lis[i], threshold);
95
- }
96
-
97
- var visible = (count > 0) ? 1 : 0;
98
- if (visible) {
99
- node.style.display = 'block';
100
- }
101
- else {
102
- node.style.display = 'none';
103
- }
104
- return visible;
105
- }
106
-
107
- function toggleChildren(img, event) {
108
- event.cancelBubble=true;
109
- if (img.className.indexOf('empty') > -1)
110
- return;
111
-
112
- var minus = (img.className.indexOf('minus') > -1);
113
-
114
- if (minus) {
115
- img.className = 'toggle plus';
116
- }
117
- else
118
- img.className = 'toggle minus';
119
-
120
- var li = img.parentNode;
121
- var ul = findUlChild(li);
122
- if (ul) {
123
- if (minus)
124
- ul.style.display = 'none';
125
- else
126
- ul.style.display = 'block';
127
- }
128
- if (minus)
129
- moveSelectionIfNecessary(li);
130
- }
131
-
132
- function showChildren(li) {
133
- var img = li.firstChild;
134
- if (img.className.indexOf('empty') > -1)
135
- return;
136
- img.className = 'toggle minus';
137
-
138
- var ul = findUlChild(li);
139
- if (ul) {
140
- ul.style.display = 'block';
141
- }
142
- }
143
-
144
- function setThreshold() {
145
- var tv = document.getElementById("threshold").value;
146
- if (tv.match(/[0-9]+([.,][0-9]+)?/)) {
147
- var f = parseFloat(tv.replace(/,/, '.'));
148
- var threads = document.getElementsByName("thread");
149
- var l = threads.length;
150
- for ( var i = 0; i < l ; i++ ) {
151
- setThresholdUL(threads[i], f);
152
- }
153
- var p = selectedNode;
154
- while (p && p.style.display=='none')
155
- p=p.parentNode.parentNode;
156
- if (p && p.nodeName=="LI")
157
- selectNode(p);
158
- }
159
- else {
160
- alert("Please specify a decimal number as threshold value!");
161
- }
162
- }
163
-
164
- function expandAll(event) {
165
- toggleAll(event, true);
166
- }
167
-
168
- function collapseAll(event) {
169
- toggleAll(event, false);
170
- selectNode(rootNode(), null);
171
- }
172
-
173
- function toggleAll(event, show) {
174
- event.cancelBubble=true;
175
- var threads = document.getElementsByName("thread");
176
- var l = threads.length;
177
- for ( var i = 0; i < l ; i++ ) {
178
- showUL(threads[i], show);
179
- }
180
- }
181
-
182
- function toggleHelp(node) {
183
- var help = document.getElementById("help");
184
- if (node.value == "Show Help") {
185
- node.value = "Hide Help";
186
- help.style.display = 'block';
187
- }
188
- else {
189
- node.value = "Show Help";
190
- help.style.display = 'none';
191
- }
192
- }
193
-
194
- var selectedNode = null;
195
- var selectedColor = null;
196
- var selectedThread = null;
197
-
198
- function descendentOf(a,b){
199
- while (a!=b && b!=null)
200
- b=b.parentNode;
201
- return (a==b);
202
- }
203
-
204
- function moveSelectionIfNecessary(node){
205
- if (descendentOf(node, selectedNode))
206
- selectNode(node, null);
207
- }
208
-
209
- function selectNode(node, event) {
210
- if (event) {
211
- event.cancelBubble = true;
212
- thread = findThread(node);
213
- selectThread(thread);
214
- }
215
- if (selectedNode) {
216
- selectedNode.style.background = selectedColor;
217
- }
218
- selectedNode = node;
219
- selectedColor = node.style.background;
220
- selectedNode.style.background = "red";
221
- selectedNode.scrollIntoView();
222
- window.scrollBy(0,-400);
223
- }
224
-
225
- function moveUp(){
226
- move(selectedNode.previousSibling);
227
- }
228
-
229
- function moveDown(){
230
- move(selectedNode.nextSibling);
231
- }
232
-
233
- function move(p) {
234
- while (p && p.style.display == 'none')
235
- p = p.nextSibling;
236
- if (p && p.nodeName == "LI") {
237
- selectNode(p, null);
238
- }
239
- }
240
-
241
- function moveLeft(){
242
- var p = selectedNode.parentNode.parentNode;
243
- if (p && p.nodeName=="LI") {
244
- selectNode(p, null);
245
- }
246
- }
247
-
248
- function moveRight(){
249
- if (!isLeafNode(selectedNode)) {
250
- showChildren(selectedNode);
251
- var ul = findUlChild(selectedNode);
252
- if (ul) {
253
- selectNode(ul.firstChild, null);
254
- }
255
- }
256
- }
257
-
258
- function moveForward(){
259
- if (isLeafNode(selectedNode)) {
260
- var p = selectedNode;
261
- while ((p.nextSibling == null || p.nextSibling.style.display=='none') && p.nodeName=="LI") {
262
- p = p.parentNode.parentNode;
263
- }
264
- if (p.nodeName=="LI")
265
- selectNode(p.nextSibling, null);
266
- }
267
- else {
268
- moveRight();
269
- }
270
- }
271
-
272
- function isExpandedNode(li){
273
- var img = li.firstChild;
274
- return(img.className.indexOf('minus')>-1);
275
- }
276
-
277
- function moveBackward(){
278
- var p = selectedNode;
279
- var q = p.previousSibling;
280
- while (q != null && q.style.display=='none')
281
- q = q.previousSibling;
282
- if (q == null) {
283
- p = p.parentNode.parentNode;
284
- } else {
285
- while (!isLeafNode(q) && isExpandedNode(q)) {
286
- q = findUlChild(q).lastChild;
287
- while (q.style.display=='none')
288
- q = q.previousSibling;
289
- }
290
- p = q;
291
- }
292
- if (p.nodeName=="LI")
293
- selectNode(p, null);
294
- }
295
-
296
- function moveHome() {
297
- selectNode(currentThread);
298
- }
299
-
300
- var currentThreadIndex = null;
301
-
302
- function findThread(node){
303
- while (node && !node.parentNode.nodeName.match(/BODY|DIV/g)) {
304
- node = node.parentNode;
305
- }
306
- return node.firstChild;
307
- }
308
-
309
- function selectThread(node){
310
- var threads = document.getElementsByName("thread");
311
- currentThread = node;
312
- for (var i=0; i<threads.length; i++) {
313
- if (threads[i]==currentThread.parentNode)
314
- currentThreadIndex = i;
315
- }
316
- }
317
-
318
- function nextThread(){
319
- var threads = document.getElementsByName("thread");
320
- if (currentThreadIndex==threads.length-1)
321
- currentThreadIndex = 0;
322
- else
323
- currentThreadIndex += 1
324
- currentThread = threads[currentThreadIndex].firstChild;
325
- selectNode(currentThread, null);
326
- }
327
-
328
- function previousThread(){
329
- var threads = document.getElementsByName("thread");
330
- if (currentThreadIndex==0)
331
- currentThreadIndex = threads.length-1;
332
- else
333
- currentThreadIndex -= 1
334
- currentThread = threads[currentThreadIndex].firstChild;
335
- selectNode(currentThread, null);
336
- }
337
-
338
- function switchThread(node, event){
339
- event.cancelBubble = true;
340
- selectThread(node.nextSibling.firstChild);
341
- selectNode(currentThread, null);
342
- }
343
-
344
- function handleKeyEvent(event){
345
- var code = event.charCode ? event.charCode : event.keyCode;
346
- var str = String.fromCharCode(code);
347
- switch (str) {
348
- case "a": moveLeft(); break;
349
- case "s": moveDown(); break;
350
- case "d": moveRight(); break;
351
- case "w": moveUp(); break;
352
- case "f": moveForward(); break;
353
- case "b": moveBackward(); break;
354
- case "x": toggleChildren(selectedNode.firstChild, event); break;
355
- case "*": toggleLI(selectedNode); break;
356
- case "n": nextThread(); break;
357
- case "h": moveHome(); break;
358
- case "p": previousThread(); break;
359
- }
360
- }
361
- document.onkeypress=function(event){ handleKeyEvent(event) };
362
-
363
- window.onload=function(){
364
- var images = document.querySelectorAll(".toggle");
365
- for (var i=0; i<images.length; i++) {
366
- var img = images[i];
367
- img.onclick = function(event){ toggleChildren(this, event); return false; };
368
- }
369
- var divs = document.getElementsByTagName("div");
370
- for (i=0; i<divs.length; i++) {
371
- var div = divs[i];
372
- if (div.className == "thread")
373
- div.onclick = function(event){ switchThread(this, event) };
374
- }
375
- var lis = document.getElementsByTagName("li");
376
- for (var i=0; i<lis.length; i++) {
377
- lis[i].onclick = function(event){ selectNode(this, event); };
378
- }
379
- var threads = document.getElementsByName("thread");;
380
- currentThreadIndex = 0;
381
- currentThread = threads[0].firstChild;
382
- selectNode(currentThread, null);
383
- };
384
-
385
- </script>