Skip to content

Commit 62d9cc2

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Extract aggregated_heap_profile_info
Summary: This function is public in the following diff D38518063. Reviewed By: bobyangyf Differential Revision: D38508091 fbshipit-source-id: 98f4098f5dc5636550149abf2821257a487c4550
1 parent bc18bda commit 62d9cc2

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

starlark/src/environment/modules.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,23 @@ impl FrozenModule {
217217
}
218218
}
219219

220-
/// Write heap flame profile of retained memory if heap profiling enabled.
221-
pub fn gen_heap_flame_profile(&self) -> anyhow::Result<String> {
222-
Ok(self
223-
.module
220+
/// Retained memory info, or error if not enabled.
221+
fn aggregated_heap_profile_info(&self) -> anyhow::Result<&AggregateHeapProfileInfo> {
222+
self.module
224223
.0
225224
.heap_profile
226225
.as_ref()
227-
.ok_or(ModuleError::RetainedMemoryProfileNotEnabled)?
228-
.gen_flame_graph())
226+
.ok_or_else(|| ModuleError::RetainedMemoryProfileNotEnabled.into())
227+
}
228+
229+
/// Write heap flame profile of retained memory if heap profiling enabled.
230+
pub fn gen_heap_flame_profile(&self) -> anyhow::Result<String> {
231+
Ok(self.aggregated_heap_profile_info()?.gen_flame_graph())
229232
}
230233

231234
/// Write heap summary profile of retained memory if heap profiling enabled.
232235
pub fn gen_heap_summary_profile(&self) -> anyhow::Result<String> {
233-
Ok(self
234-
.module
235-
.0
236-
.heap_profile
237-
.as_ref()
238-
.ok_or(ModuleError::RetainedMemoryProfileNotEnabled)?
239-
.gen_summary_csv())
236+
Ok(self.aggregated_heap_profile_info()?.gen_summary_csv())
240237
}
241238
}
242239

0 commit comments

Comments
 (0)