ruby-prof 1.0.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 (97) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +523 -0
  3. data/LICENSE +25 -0
  4. data/README.rdoc +5 -0
  5. data/Rakefile +110 -0
  6. data/bin/ruby-prof +380 -0
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +36 -0
  9. data/ext/ruby_prof/rp_allocation.c +292 -0
  10. data/ext/ruby_prof/rp_allocation.h +31 -0
  11. data/ext/ruby_prof/rp_call_info.c +283 -0
  12. data/ext/ruby_prof/rp_call_info.h +35 -0
  13. data/ext/ruby_prof/rp_measure_allocations.c +52 -0
  14. data/ext/ruby_prof/rp_measure_memory.c +42 -0
  15. data/ext/ruby_prof/rp_measure_process_time.c +63 -0
  16. data/ext/ruby_prof/rp_measure_wall_time.c +62 -0
  17. data/ext/ruby_prof/rp_measurement.c +236 -0
  18. data/ext/ruby_prof/rp_measurement.h +49 -0
  19. data/ext/ruby_prof/rp_method.c +642 -0
  20. data/ext/ruby_prof/rp_method.h +70 -0
  21. data/ext/ruby_prof/rp_profile.c +881 -0
  22. data/ext/ruby_prof/rp_profile.h +36 -0
  23. data/ext/ruby_prof/rp_stack.c +196 -0
  24. data/ext/ruby_prof/rp_stack.h +56 -0
  25. data/ext/ruby_prof/rp_thread.c +338 -0
  26. data/ext/ruby_prof/rp_thread.h +36 -0
  27. data/ext/ruby_prof/ruby_prof.c +48 -0
  28. data/ext/ruby_prof/ruby_prof.h +17 -0
  29. data/ext/ruby_prof/vc/ruby_prof.sln +31 -0
  30. data/ext/ruby_prof/vc/ruby_prof.vcxproj +143 -0
  31. data/lib/ruby-prof.rb +53 -0
  32. data/lib/ruby-prof/assets/call_stack_printer.css.html +117 -0
  33. data/lib/ruby-prof/assets/call_stack_printer.js.html +385 -0
  34. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  35. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  36. data/lib/ruby-prof/call_info.rb +57 -0
  37. data/lib/ruby-prof/call_info_visitor.rb +38 -0
  38. data/lib/ruby-prof/compatibility.rb +109 -0
  39. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  40. data/lib/ruby-prof/measurement.rb +14 -0
  41. data/lib/ruby-prof/method_info.rb +90 -0
  42. data/lib/ruby-prof/printers/abstract_printer.rb +118 -0
  43. data/lib/ruby-prof/printers/call_info_printer.rb +51 -0
  44. data/lib/ruby-prof/printers/call_stack_printer.rb +269 -0
  45. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -0
  46. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  47. data/lib/ruby-prof/printers/flat_printer.rb +52 -0
  48. data/lib/ruby-prof/printers/graph_html_printer.rb +64 -0
  49. data/lib/ruby-prof/printers/graph_printer.rb +114 -0
  50. data/lib/ruby-prof/printers/multi_printer.rb +127 -0
  51. data/lib/ruby-prof/profile.rb +33 -0
  52. data/lib/ruby-prof/rack.rb +171 -0
  53. data/lib/ruby-prof/task.rb +147 -0
  54. data/lib/ruby-prof/thread.rb +35 -0
  55. data/lib/ruby-prof/version.rb +3 -0
  56. data/lib/unprof.rb +10 -0
  57. data/ruby-prof.gemspec +58 -0
  58. data/test/abstract_printer_test.rb +26 -0
  59. data/test/alias_test.rb +129 -0
  60. data/test/basic_test.rb +129 -0
  61. data/test/call_info_visitor_test.rb +31 -0
  62. data/test/duplicate_names_test.rb +32 -0
  63. data/test/dynamic_method_test.rb +53 -0
  64. data/test/enumerable_test.rb +21 -0
  65. data/test/exceptions_test.rb +24 -0
  66. data/test/exclude_methods_test.rb +146 -0
  67. data/test/exclude_threads_test.rb +53 -0
  68. data/test/line_number_test.rb +161 -0
  69. data/test/marshal_test.rb +119 -0
  70. data/test/measure_allocations.rb +30 -0
  71. data/test/measure_allocations_test.rb +385 -0
  72. data/test/measure_allocations_trace_test.rb +385 -0
  73. data/test/measure_memory_trace_test.rb +756 -0
  74. data/test/measure_process_time_test.rb +849 -0
  75. data/test/measure_times.rb +54 -0
  76. data/test/measure_wall_time_test.rb +459 -0
  77. data/test/multi_printer_test.rb +71 -0
  78. data/test/no_method_class_test.rb +15 -0
  79. data/test/parser_timings.rb +24 -0
  80. data/test/pause_resume_test.rb +166 -0
  81. data/test/prime.rb +56 -0
  82. data/test/printer_call_tree_test.rb +31 -0
  83. data/test/printer_flat_test.rb +68 -0
  84. data/test/printer_graph_html_test.rb +60 -0
  85. data/test/printer_graph_test.rb +41 -0
  86. data/test/printers_test.rb +141 -0
  87. data/test/printing_recursive_graph_test.rb +81 -0
  88. data/test/rack_test.rb +157 -0
  89. data/test/recursive_test.rb +210 -0
  90. data/test/singleton_test.rb +38 -0
  91. data/test/stack_printer_test.rb +64 -0
  92. data/test/start_stop_test.rb +109 -0
  93. data/test/test_helper.rb +24 -0
  94. data/test/thread_test.rb +144 -0
  95. data/test/unique_call_path_test.rb +190 -0
  96. data/test/yarv_test.rb +56 -0
  97. metadata +189 -0
@@ -0,0 +1,385 @@
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>
@@ -0,0 +1,356 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <style media="all" type="text/css">
5
+ body {
6
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
7
+ background-color: #F5F7FB;
8
+ margin: 0;
9
+ padding: 0;
10
+ font-size: 16px;
11
+ }
12
+
13
+ table {
14
+ border-collapse: collapse;
15
+ /* border: 1px solid #E1E3E7; */
16
+ border: 1px solid #F3F9FE;
17
+ font-size: 14px;
18
+ line-height: normal;
19
+ width: 100%;
20
+ }
21
+
22
+ table:empty {
23
+ display: none;
24
+ }
25
+
26
+ th:first-child {
27
+ border-left: 0;
28
+ }
29
+
30
+ th {
31
+ text-align: center;
32
+ background: #F3F9FE;
33
+ padding: 1rem;
34
+ /* border-left: 1px solid #E1E3E7; */
35
+ text-transform: uppercase;
36
+ font-size: 13px;
37
+ letter-spacing: 1px;
38
+ }
39
+
40
+ tr.break td {
41
+ border: 0;
42
+ border-top: 1px solid #BDC3DD;
43
+ padding: 0;
44
+ margin: 0;
45
+ }
46
+
47
+ tr.method td {
48
+ font-weight: bold;
49
+ }
50
+
51
+ td {
52
+ padding: 0.5em;
53
+ }
54
+
55
+ td:first-child {
56
+ width: 190px;
57
+ }
58
+
59
+ tr > td > table {
60
+ box-shadow: 0px -2px 1px #F9FAFB, 0px 1px 1px #E4EEEE, 0px 1px 2px #EEF3F8;
61
+ border-radius: 2px;
62
+ overflow: hidden;
63
+ }
64
+
65
+ tr.break + tr > td.method_name {
66
+ font-weight: bold;
67
+ }
68
+
69
+ td {
70
+ /* I'm removing this border because I think it looks way cleaner without it but feel free to add it if you feel it's necessary */
71
+ /* border-left: 1px solid #E1E3E7; */
72
+ text-align: center;
73
+ }
74
+
75
+ a {
76
+ text-decoration: none;
77
+ }
78
+
79
+ .method_name {
80
+ text-align: left;
81
+ }
82
+
83
+ tfoot td {
84
+ text-align: left;
85
+ }
86
+
87
+ .report-header {
88
+ background-color: #0D2483;
89
+ color: white;
90
+ padding: 1.5rem 2rem;
91
+ }
92
+
93
+ .report-header > div {
94
+ display: flex;
95
+ flex-direction: row;
96
+ align-items: center;
97
+ }
98
+
99
+ .report-header h1 {
100
+ margin-bottom: 0;
101
+ }
102
+
103
+ h1, h2, h3, h4, h5, h6 {
104
+ margin-top: 0;
105
+ margin-bottom: 0.5rem;
106
+ }
107
+
108
+ h6 {
109
+ font-size: 0.75rem;
110
+ text-transform: uppercase;
111
+ letter-spacing: 1.5px;
112
+ color: rgba(255, 255, 255, 0.6);
113
+ }
114
+
115
+ .table-header {
116
+ padding: 3rem 0 1rem;
117
+ }
118
+
119
+ .table-wrapper {
120
+ margin: 1rem auto;
121
+ max-width: 1440px;
122
+ padding: 4rem 5rem;
123
+ background: white;
124
+ border-radius: 0.5rem;
125
+ }
126
+
127
+ .center {
128
+ max-width: 1440px;
129
+ margin: 0 auto;
130
+ }
131
+
132
+ .layout-right {
133
+ margin-left: auto;
134
+ }
135
+
136
+ .text-right {
137
+ display: flex;
138
+ align-items: flex-end;
139
+ flex-direction: column;
140
+ }
141
+
142
+ .timestamp {
143
+ font-size: 12px;
144
+ margin-bottom: 1rem;
145
+ color: rgba(255, 255, 255, 0.6);
146
+ }
147
+
148
+ .logo {
149
+ width: 140px;
150
+ height: 30px;
151
+ opacity: 0.5;
152
+ background-repeat: no-repeat;
153
+ background-image: url("data:image/svg+xml,%3Csvg id='Layer_1' data-name='Layer 1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 190 41'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M63.49 16.74c0-1.37-.91-2-2.26-2h-3.38v3.93h3.58c1.24.01 2.06-.56 2.06-1.93zM110.43 14.75h-3.6v5h3.6a2.32 2.32 0 0 0 2.5-2.49 2.34 2.34 0 0 0-2.5-2.51zM128.77 14.75h-3.53v4.94h3.53a2.28 2.28 0 0 0 2.47-2.45 2.3 2.3 0 0 0-2.47-2.49zM61.81 21.83h-4v4.32h3.91c1.44 0 2.45-.62 2.45-2.14s-.99-2.18-2.36-2.18zM21 14.75h-3.57v4.94H21a2.28 2.28 0 0 0 2.47-2.45A2.3 2.3 0 0 0 21 14.75z'/%3E%3Cpath class='cls-1' d='M184 .44H5.87A4.93 4.93 0 0 0 .94 5.37V35.5a4.94 4.94 0 0 0 4.93 4.94H184a4.94 4.94 0 0 0 4.94-4.94V5.37A4.94 4.94 0 0 0 184 .44zm-34.38 10.78c4.79 0 8.46 2.89 9.18 7.54h-3.86a5.48 5.48 0 0 0-10.68 0h-3.83c.71-4.65 4.36-7.54 9.19-7.54zM24 29.44L20.46 23h-3v6.46h-3.72v-18h7.68c3.41 0 5.78 2.07 5.78 5.76a5.34 5.34 0 0 1-2.88 5.14l3.82 7.06zm24.31-7.3c0 4.8-2.92 7.56-7.63 7.56S33 26.94 33 22.14V11.48h3.69v10.61c0 2.81 1.37 4.32 4 4.32s3.94-1.51 3.94-4.32V11.48h3.69zm13.92 7.3h-8v-18h7.52c3.24 0 5.59 1.61 5.59 5A4 4 0 0 1 65.51 20 4.22 4.22 0 0 1 68 24.21c0 3.43-2.4 5.23-5.81 5.23zm19.66-6.92v6.92h-3.7v-6.92l-6.81-11h4.29L80 18.85l4.34-7.37h4.32zm16-.5h-7.62v-3.26h7.59zm13 1h-4v6.39h-3.72v-18h7.77c3.41 0 5.79 2.09 5.79 5.79s-2.41 5.85-5.82 5.85zm20.86 6.39L128.26 23h-3v6.46h-3.72v-18h7.69c3.4 0 5.78 2.07 5.78 5.76a5.34 5.34 0 0 1-2.88 5.14l3.87 7.08zm17.85.26c-4.88 0-8.55-2.95-9.21-7.68h3.81A5.49 5.49 0 0 0 155 22h3.84c-.69 4.75-4.38 7.7-9.22 7.7zm18.4-.23h-3.72v-3.7H168zm6.36-7.54h-10.05v-3.26h10.08zm1.44-7.16h-11.49v-3.26h11.52z'/%3E%3C/svg%3E");
154
+ }
155
+ </style>
156
+ </head>
157
+ <body>
158
+ <div class="report-header">
159
+ <div class="center">
160
+ <div class="layout-left">
161
+ <h6>Profile Report</h6>
162
+ <h1><%= @result.measure_mode_string.capitalize %></h1>
163
+ </div>
164
+ <div class="layout-right text-right">
165
+ <div class="timestamp"><%= Time.now.strftime(self.time_format) %></div>
166
+ <div class="logo"></div>
167
+ </div>
168
+ </div>
169
+ </div>
170
+ <div class="table-wrapper">
171
+ <table>
172
+ <tr>
173
+ <th>Thread ID</th>
174
+ <th>Fiber ID</th>
175
+ <th>Total</th>
176
+ </tr>
177
+ <% for thread in @result.threads %>
178
+ <tr>
179
+ <td><%= thread.id %></td>
180
+ <td><a href="#<%= thread.fiber_id %>"><%= thread.fiber_id %></a></td>
181
+ <td><%= thread.total_time %></td>
182
+ </tr>
183
+ <% end %>
184
+ </table>
185
+
186
+ <!-- Methods Tables -->
187
+ <%
188
+ for thread in @result.threads
189
+ methods = thread.methods
190
+ total_time = thread.total_time
191
+ %>
192
+ <h2><a name="<%= thread.fiber_id %>">Thread <%= thread.id %>, Fiber: <%= thread.fiber_id %></a></h2>
193
+ <table>
194
+ <thead>
195
+ <tr>
196
+ <th>%Total</th>
197
+ <th>%Self</th>
198
+ <th>Total</th>
199
+ <th>Self</th>
200
+ <th>Wait</th>
201
+ <th>Child</th>
202
+ <th>Calls</th>
203
+ <th class="method_name">Name</th>
204
+ <% if @result.track_allocations? %>
205
+ <th>Allocations</th>
206
+ <% end %>
207
+ <th>Line</th>
208
+ </tr>
209
+ </thead>
210
+ <tbody>
211
+ <% min_time = @options[:min_time] || (@options[:nonzero] ? 0.005 : nil)
212
+ sorted_methods = sort_method ? methods.sort_by(&sort_method) : methods.sort
213
+ sorted_methods.reverse_each do |method|
214
+ total_percentage = (method.total_time/total_time) * 100
215
+ next if total_percentage < min_percent
216
+ next if min_time && method.total_time < min_time
217
+ self_percentage = (method.self_time/total_time) * 100 %>
218
+
219
+ <!-- Parents -->
220
+ <% for caller in method.callers.sort
221
+ next if method.root?
222
+ next if min_time && caller.total_time < min_time %>
223
+ <tr>
224
+ <td>&nbsp;</td>
225
+ <td>&nbsp;</td>
226
+ <td><%= sprintf("%.2f", caller.total_time) %></td>
227
+ <td><%= sprintf("%.2f", caller.self_time) %></td>
228
+ <td><%= sprintf("%.2f", caller.wait_time) %></td>
229
+ <td><%= sprintf("%.2f", caller.children_time) %></td>
230
+ <td><%= "#{caller.called}/#{method.called}" %></td>
231
+ <td class="method_name"><%= create_link(thread, total_time, caller.parent) %></td>
232
+ <% if @result.track_allocations? %>
233
+ <td>-</td>
234
+ <% end %>
235
+ <td><%= if caller.parent.source_file
236
+ file_link(caller.parent.source_file, caller.line)
237
+ end %></td>
238
+ </tr>
239
+ <% end %>
240
+ <tr class="method">
241
+ <td><%= sprintf("%.2f%%", total_percentage) %></td>
242
+ <td><%= sprintf("%.2f%%", self_percentage) %></td>
243
+ <td><%= sprintf("%.2f", method.total_time) %></td>
244
+ <td><%= sprintf("%.2f", method.self_time) %></td>
245
+ <td><%= sprintf("%.2f", method.wait_time) %></td>
246
+ <td><%= sprintf("%.2f", method.children_time) %></td>
247
+ <td><%= sprintf("%i", method.called) %></td>
248
+ <td class="method_name">
249
+ <a name="<%= method_href(thread, method) %>">
250
+ <%= method.recursive? ? "*" : " " %><%= h method.full_name %>
251
+ </a>
252
+ </td>
253
+
254
+ <% if @result.track_allocations? %>
255
+ <td>
256
+ <% count = method.allocations.reduce(0) do |size, allocation|
257
+ size += allocation.count
258
+ end %>
259
+ <% if count > 0 %>
260
+ <a class="allocations" href="#<%= method_href(thread, method) %>_allocations" %><%= count %></a>
261
+ <% else %>
262
+ 0
263
+ <% end %>
264
+ </td>
265
+ <% end %>
266
+
267
+ <td><%= if method.source_file
268
+ file_link(method.source_file, method.line)
269
+ end %></td>
270
+ </tr>
271
+
272
+ <% if @result.track_allocations? %>
273
+ <tr>
274
+ <td colspan="10">
275
+ <table id="<%= method_href(thread, method) %>_allocations" class="allocations" style="display: none">
276
+ <% for allocation in method.allocations %>
277
+ <tr>
278
+ <td>
279
+ <%= allocation.klass_name %>
280
+ </td>
281
+ <td>
282
+ <%= "#{allocation.count} (#{allocation.memory} Bytes)" %>
283
+ </td>
284
+ <td>
285
+ <%= "#{allocation.source_file}:#{allocation.line}" %>
286
+ </td>
287
+ </tr>
288
+ <% end %>
289
+ </table>
290
+
291
+ </td>
292
+ </tr>
293
+ <% end %>
294
+
295
+ <!-- Children -->
296
+ <% for callee in method.callees.sort_by(&:total_time).reverse
297
+ next if min_time && callee.total_time < min_time %>
298
+ <tr>
299
+ <td>&nbsp;</td>
300
+ <td>&nbsp;</td>
301
+ <td><%= sprintf("%.2f", callee.total_time) %></td>
302
+ <td><%= sprintf("%.2f", callee.self_time) %></td>
303
+ <td><%= sprintf("%.2f", callee.wait_time) %></td>
304
+ <td><%= sprintf("%.2f", callee.children_time) %></td>
305
+ <td><%= "#{callee.called}/#{callee.target.called}" %></td>
306
+ <td class="method_name"><%= create_link(thread, total_time, callee.target) %></td>
307
+ <% if @result.track_allocations? %>
308
+ <td>-</td>
309
+ <% end %>
310
+ <td><%= file_link(callee.source_file, callee.line) %>
311
+ </tr>
312
+ <% end %>
313
+
314
+ <!-- Create divider row -->
315
+ <tr class="break">
316
+ <td colspan="10"></td>
317
+ </tr>
318
+ <% end %>
319
+ </tbody>
320
+ <tfoot>
321
+ <tr>
322
+ <td colspan="9">* indicates recursively called methods</td>
323
+ </tr>
324
+ </tfoot>
325
+ </table>
326
+ <% end %>
327
+ </div>
328
+
329
+ <script type="application/javascript">
330
+ function toggleAllocations(element)
331
+ {
332
+ if (element.style.display == 'none')
333
+ element.style.display = 'block'
334
+ else
335
+ element.style.display = 'none'
336
+ }
337
+
338
+ function onClick(event)
339
+ {
340
+ if (event.target.tagName == 'A' && event.target.classList.contains('allocations'))
341
+ {
342
+ var url = new URL(event.target.href)
343
+ var element = document.querySelector(url.hash)
344
+ toggleAllocations(element)
345
+ event.preventDefault()
346
+ }
347
+ }
348
+
349
+ window.addEventListener('DOMContentLoaded', function(event)
350
+ {
351
+ document.addEventListener('click', onClick)
352
+ })
353
+
354
+ </script>
355
+ </body>
356
+ </html>