test-prof-autopilot 0.1.0.pre.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55e6d41b4c30aa3390d97e550a425e92125e6ee74e4ffe6a3e2660be5f5e1795
4
- data.tar.gz: 866cc0632a7304a5e675ae78541e77f304de4eeba781f8987a6f8d0563eba3db
3
+ metadata.gz: 254d657c3dc55ab41d3834aa7470be97aa17bf27130e8073849784519ba41dc2
4
+ data.tar.gz: 1311b34585cbaa6ca232bb2e718abe4f7e69ab04a563458ca479037d2fb6d48a
5
5
  SHA512:
6
- metadata.gz: 2ffc441d899c9fa8c2fcaec24930016ee0677705153dd4528aa19e9b48637563a06a0573e001c069d2f04ef5cf4964a49f6380afaefbb263c7b66b0ae8673b19
7
- data.tar.gz: 389c5d56dbdc4553d21850f964d5880c0de8a2cde0c9938c65a390de84556b326d3abf8cdc71ad5626461e572e7021697f2272edeb8e34ac1a427f632fafa6f4
6
+ metadata.gz: 467db9623c7dea50c2689849b3afe2e1b994c8e3ed05bcb8a4de7dcbcb7279e6d6c9be0cff0880bc2651006e6ce46d606299f55214931f34944ab1ded3ae5fa1
7
+ data.tar.gz: 144c90bcecb8bc2780606d85c3029883667f6fa2c9a27b191f783d823c19e66698c7062cb5f24621a09cb466005c060c19fa375ef59e8be57b0dccbfea73d77c
data/CHANGELOG.md CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.0 (2023-11-21)
6
+
7
+ - Initial public release. ([@palkan][])
8
+
5
9
  [@palkan]: https://github.com/palkan
@@ -24,32 +24,53 @@ module TestProf
24
24
  end
25
25
 
26
26
  def merge(other)
27
- f1, f2 = data[:frames], other.data[:frames]
28
-
29
- frames = (f1.keys + f2.keys).uniq.each_with_object({}) do |id, hash|
30
- if f1[id].nil?
31
- hash[id] = f2[id]
32
- elsif f2[id]
33
- hash[id] = f1[id]
34
- hash[id][:total_samples] += f2[id][:total_samples]
35
- hash[id][:samples] += f2[id][:samples]
36
- if f2[id][:edges]
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
- if f2[id][:lines]
44
- lines = hash[id][:lines] ||= {}
45
- f2[id][:lines].each do |line, weight|
46
- lines[line] = add_lines(lines[line], weight)
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
- hash
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] + d2[: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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TestProf
4
4
  module Autopilot # :nodoc:
5
- VERSION = "0.1.0.pre.1"
5
+ VERSION = "0.1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof-autopilot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Shakirov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-15 00:00:00.000000000 Z
12
+ date: 2023-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-prof
@@ -149,9 +149,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  version: '2.7'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ">"
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 1.3.1
154
+ version: '0'
155
155
  requirements: []
156
156
  rubygems_version: 3.4.20
157
157
  signing_key: