@@ -125,6 +125,17 @@ impl ProfileData {
125
125
let profile = BcPairsProfileData :: merge ( profiles) ;
126
126
ProfileDataImpl :: BcPairs ( profile)
127
127
}
128
+ ProfileMode :: HeapSummaryAllocated
129
+ | ProfileMode :: HeapSummaryRetained
130
+ | ProfileMode :: HeapFlameAllocated
131
+ | ProfileMode :: HeapFlameRetained => {
132
+ let profiles = profiles. try_map ( |p| match & p. profile {
133
+ ProfileDataImpl :: AggregateHeapProfileInfo ( profile) => Ok ( & * * profile) ,
134
+ _ => Err ( ProfileDataError :: ProfileDataNotConsistent ) ,
135
+ } ) ?;
136
+ let profile = AggregateHeapProfileInfo :: merge ( profiles) ;
137
+ ProfileDataImpl :: AggregateHeapProfileInfo ( box profile)
138
+ }
128
139
profile_mode => {
129
140
return Err ( ProfileDataError :: MergeNotImplemented ( profile_mode. dupe ( ) ) . into ( ) ) ;
130
141
}
@@ -138,11 +149,14 @@ impl ProfileData {
138
149
139
150
#[ cfg( test) ]
140
151
mod tests {
152
+ use gazebo:: dupe:: Dupe ;
153
+
141
154
use crate :: eval:: runtime:: profile:: bc:: BcPairsProfileData ;
142
155
use crate :: eval:: runtime:: profile:: bc:: BcProfileData ;
143
156
use crate :: eval:: runtime:: profile:: data:: ProfileDataImpl ;
144
157
use crate :: eval:: ProfileData ;
145
158
use crate :: eval:: ProfileMode ;
159
+ use crate :: values:: AggregateHeapProfileInfo ;
146
160
147
161
#[ test]
148
162
fn merge_bc ( ) {
@@ -163,4 +177,23 @@ mod tests {
163
177
// Smoke.
164
178
ProfileData :: merge ( [ & profile, & profile] ) . unwrap ( ) ;
165
179
}
180
+
181
+ #[ test]
182
+ fn merge_aggregated_heap_profile ( ) {
183
+ for profile_mode in [
184
+ ProfileMode :: HeapFlameRetained ,
185
+ ProfileMode :: HeapFlameAllocated ,
186
+ ProfileMode :: HeapSummaryRetained ,
187
+ ProfileMode :: HeapSummaryAllocated ,
188
+ ] {
189
+ let profile = ProfileData {
190
+ profile_mode : profile_mode. dupe ( ) ,
191
+ profile : ProfileDataImpl :: AggregateHeapProfileInfo (
192
+ box AggregateHeapProfileInfo :: default ( ) ,
193
+ ) ,
194
+ } ;
195
+ // Smoke.
196
+ ProfileData :: merge ( [ & profile, & profile] ) . unwrap ( ) ;
197
+ }
198
+ }
166
199
}
0 commit comments