test-prof-autopilot 0.1.0.pre.1 → 0.1.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_prof/autopilot/stack_prof/report.rb +70 -23
- data/lib/test_prof/autopilot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ee9039d6d83bbf54010e2ebda79747d5ad7511cb7cff65eb1d1064f72561692
|
4
|
+
data.tar.gz: fc3b28fc007dcfefddf66dd4b045befb745db2aa3dc09ca591ae3a75cee45b73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9540aa726621514223f0f48a02b27e13c1082b27596093d610b19fd0d885dcb416f6336c03e631fb4d51a10ea57a21ccbb671312b0ca9a02a36a8e73c5225412
|
7
|
+
data.tar.gz: 6d16c822426a62e6ac7ad8d8a0d747d0e61e2850e23252ec9b9753f5ec735cb9b64ff28bb5e071614359a04314ba8eff25d08eb433e4319bfbd53337562808ce
|
@@ -24,32 +24,53 @@ module TestProf
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def merge(other)
|
27
|
-
|
28
|
-
|
29
|
-
frames =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
edges = hash[id][:edges] ||= {}
|
38
|
-
f2[id][:edges].each do |edge, weight|
|
39
|
-
edges[edge] ||= 0
|
40
|
-
edges[edge] += weight
|
41
|
-
end
|
27
|
+
ids_mapping = generate_ids_mapping(data[:frames], other.data[:frames])
|
28
|
+
|
29
|
+
frames = data[:frames].dup
|
30
|
+
|
31
|
+
other.data[:frames].each do |id, new_frame|
|
32
|
+
frame =
|
33
|
+
if ids_mapping[id]
|
34
|
+
frames[ids_mapping[id]]
|
35
|
+
else
|
36
|
+
frames[id] = empty_frame_from(new_frame)
|
42
37
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
|
39
|
+
frame[:total_samples] += new_frame[:total_samples]
|
40
|
+
frame[:samples] += new_frame[:samples]
|
41
|
+
|
42
|
+
if new_frame[:edges]
|
43
|
+
edges = (frame[:edges] ||= {})
|
44
|
+
|
45
|
+
new_frame[:edges].each do |edge, weight|
|
46
|
+
old_edge = ids_mapping[edge]
|
47
|
+
|
48
|
+
if edges[old_edge]
|
49
|
+
edges[old_edge] += weight
|
50
|
+
else
|
51
|
+
edges[old_edge] = weight
|
47
52
|
end
|
48
53
|
end
|
49
|
-
else
|
50
|
-
hash[id] = f1[id]
|
51
54
|
end
|
52
|
-
|
55
|
+
|
56
|
+
if new_frame[:lines]
|
57
|
+
lines = (frame[:lines] ||= {})
|
58
|
+
|
59
|
+
new_frame[:lines].each do |line, weight|
|
60
|
+
old_line = ids_mapping[line]
|
61
|
+
|
62
|
+
lines[old_line] =
|
63
|
+
if lines[old_line]
|
64
|
+
add_lines(lines[old_line], weight)
|
65
|
+
else
|
66
|
+
weight
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
converted_raw = other.data[:raw].map do |raw|
|
73
|
+
ids_mapping[raw] || raw
|
53
74
|
end
|
54
75
|
|
55
76
|
d1, d2 = data, other.data
|
@@ -62,12 +83,38 @@ module TestProf
|
|
62
83
|
missed_samples: d1[:missed_samples] + d2[:missed_samples],
|
63
84
|
metadata: d1[:metadata].merge(d2[:metadata]),
|
64
85
|
frames: frames,
|
65
|
-
raw: d1[:raw] +
|
86
|
+
raw: d1[:raw] + converted_raw,
|
66
87
|
raw_timestamp_deltas: d1[:raw_timestamp_deltas] + d2[:raw_timestamp_deltas]
|
67
88
|
}
|
68
89
|
|
69
90
|
self.class.new(data)
|
70
91
|
end
|
92
|
+
|
93
|
+
def generate_ids_mapping(frames, other_frames)
|
94
|
+
old_fingerprints = frames_to_fingerprints(frames)
|
95
|
+
new_fingerprints = frames_to_fingerprints(other_frames)
|
96
|
+
|
97
|
+
new_fingerprints.each_with_object({}) do |(fingerprint, frame), hash|
|
98
|
+
next hash unless old_fingerprints[fingerprint]
|
99
|
+
|
100
|
+
hash[frame[:id]] = old_fingerprints[fingerprint][:id]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def frames_to_fingerprints(frames)
|
105
|
+
frames.each_with_object({}) do |(id, frame), hash|
|
106
|
+
fingerprint = [frame[:name], frame[:file], frame[:line]].compact.map(&:to_s).join("/")
|
107
|
+
hash[fingerprint] = frame.merge(id: id)
|
108
|
+
hash
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def empty_frame_from(frame)
|
113
|
+
frame.slice(:name, :file, :line).merge(
|
114
|
+
total_samples: 0,
|
115
|
+
samples: 0
|
116
|
+
)
|
117
|
+
end
|
71
118
|
end
|
72
119
|
end
|
73
120
|
end
|