@@ -23,11 +23,19 @@ use anyhow::Context;
2323use crate :: eval:: runtime:: profile:: bc:: BcPairsProfileData ;
2424use crate :: eval:: runtime:: profile:: bc:: BcProfileData ;
2525use crate :: eval:: ProfileMode ;
26+ use crate :: values:: AggregateHeapProfileInfo ;
27+
28+ #[ derive( Debug , thiserror:: Error ) ]
29+ enum ProfileDataError {
30+ #[ error( "Profile data is not consistent with profile mode (internal error)" ) ]
31+ ProfileDataNotConsistent ,
32+ }
2633
2734#[ derive( Clone , Debug ) ]
2835pub ( crate ) enum ProfileDataImpl {
2936 Bc ( Box < BcProfileData > ) ,
3037 BcPairs ( BcPairsProfileData ) ,
38+ AggregateHeapProfileInfo ( Box < AggregateHeapProfileInfo > ) ,
3139 Other ( String ) ,
3240}
3341
@@ -49,10 +57,21 @@ impl ProfileData {
4957
5058 /// Generate a string with profile data (e.g. CSV or flamegraph, depending on profile type).
5159 pub fn gen ( & self ) -> anyhow:: Result < String > {
52- match & self . profile {
53- ProfileDataImpl :: Other ( profile) => Ok ( profile. clone ( ) ) ,
54- ProfileDataImpl :: Bc ( bc) => Ok ( bc. gen_csv ( ) ) ,
55- ProfileDataImpl :: BcPairs ( bc_pairs) => Ok ( bc_pairs. gen_csv ( ) ) ,
60+ match ( & self . profile , & self . profile_mode ) {
61+ ( ProfileDataImpl :: Other ( profile) , _) => Ok ( profile. clone ( ) ) ,
62+ ( ProfileDataImpl :: Bc ( bc) , _) => Ok ( bc. gen_csv ( ) ) ,
63+ ( ProfileDataImpl :: BcPairs ( bc_pairs) , _) => Ok ( bc_pairs. gen_csv ( ) ) ,
64+ (
65+ ProfileDataImpl :: AggregateHeapProfileInfo ( profile) ,
66+ ProfileMode :: HeapFlameRetained | ProfileMode :: HeapFlameAllocated ,
67+ ) => Ok ( profile. gen_flame_graph ( ) ) ,
68+ (
69+ ProfileDataImpl :: AggregateHeapProfileInfo ( profile) ,
70+ ProfileMode :: HeapSummaryRetained | ProfileMode :: HeapSummaryAllocated ,
71+ ) => Ok ( profile. gen_summary_csv ( ) ) ,
72+ ( ProfileDataImpl :: AggregateHeapProfileInfo ( _) , _) => {
73+ Err ( ProfileDataError :: ProfileDataNotConsistent . into ( ) )
74+ }
5675 }
5776 }
5877
0 commit comments