rack-mini-profiler 0.1.26 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-mini-profiler might be problematic. Click here for more details.

@@ -1,54 +0,0 @@
1
- # inspired by https://github.com/brendangregg/FlameGraph
2
-
3
- class Rack::MiniProfiler::FlameGraph
4
- def initialize(stacks)
5
- @stacks = stacks
6
- end
7
-
8
- def graph_data
9
- height = 0
10
-
11
- table = []
12
- prev = []
13
-
14
- # a 2d array makes collapsing easy
15
- @stacks.each_with_index do |stack, pos|
16
- col = []
17
-
18
- stack.reverse.map{|r| r.to_s}.each_with_index do |frame, i|
19
-
20
- if !prev[i].nil?
21
- last_col = prev[i]
22
- if last_col[0] == frame
23
- last_col[1] += 1
24
- col << nil
25
- next
26
- end
27
- end
28
-
29
- prev[i] = [frame, 1]
30
- col << prev[i]
31
- end
32
- prev = prev[0..col.length-1].to_a
33
- table << col
34
- end
35
-
36
- data = []
37
-
38
- # a 1d array makes rendering easy
39
- table.each_with_index do |col, col_num|
40
- col.each_with_index do |row, row_num|
41
- next unless row && row.length == 2
42
- data << {
43
- :x => col_num + 1,
44
- :y => row_num + 1,
45
- :width => row[1],
46
- :frame => row[0]
47
- }
48
- end
49
- end
50
-
51
- data
52
- end
53
-
54
- end