Module: Profiler
- Defined in:
- lib/rails_notebook/profiler.rb
Defined Under Namespace
Classes: Profile, StackProfSampler
Class Method Summary
collapse
Class Method Details
.generate_data(stacks) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/rails_notebook/profiler.rb', line 14
def self.generate_data( stacks )
table = []
prev = []
stacks.each_with_index do |stack, pos|
next unless stack
col = []
stack.reverse.map{|r| r.to_s}.each_with_index do |frame, i|
if !prev[i].nil?
last_col = prev[i]
if last_col[0] == frame
last_col[1] += 1
col << nil
next
end
end
prev[i] = [frame, 1]
col << prev[i]
end
prev = prev[0..col.length-1].to_a
table << col
end
data = []
table.each_with_index do |col, col_num|
col.each_with_index do |row, row_num|
next unless row && row.length == 2
data << {
:x => col_num + 1,
:y => row_num + 1,
:width => row[1],
:frame => row[0]
}
end
end
data
end
|
.profile(filename = nil, opts = {}) ⇒ Object