@@ -125,6 +125,17 @@ impl ProfileData {
125125 let profile = BcPairsProfileData :: merge ( profiles) ;
126126 ProfileDataImpl :: BcPairs ( profile)
127127 }
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+ }
128139 profile_mode => {
129140 return Err ( ProfileDataError :: MergeNotImplemented ( profile_mode. dupe ( ) ) . into ( ) ) ;
130141 }
@@ -138,11 +149,14 @@ impl ProfileData {
138149
139150#[ cfg( test) ]
140151mod tests {
152+ use gazebo:: dupe:: Dupe ;
153+
141154 use crate :: eval:: runtime:: profile:: bc:: BcPairsProfileData ;
142155 use crate :: eval:: runtime:: profile:: bc:: BcProfileData ;
143156 use crate :: eval:: runtime:: profile:: data:: ProfileDataImpl ;
144157 use crate :: eval:: ProfileData ;
145158 use crate :: eval:: ProfileMode ;
159+ use crate :: values:: AggregateHeapProfileInfo ;
146160
147161 #[ test]
148162 fn merge_bc ( ) {
@@ -163,4 +177,23 @@ mod tests {
163177 // Smoke.
164178 ProfileData :: merge ( [ & profile, & profile] ) . unwrap ( ) ;
165179 }
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+ }
166199}
0 commit comments