1717
1818use std:: cell:: Cell ;
1919use std:: collections:: HashSet ;
20- use std:: fs;
2120use std:: mem;
2221use std:: mem:: MaybeUninit ;
2322use std:: path:: Path ;
2423
25- use anyhow:: Context ;
2624use gazebo:: any:: AnyLifetime ;
2725use gazebo:: cast;
2826use gazebo:: dupe:: Dupe ;
@@ -47,6 +45,7 @@ use crate::eval::runtime::call_stack::CheapCallStack;
4745use crate :: eval:: runtime:: call_stack:: FrozenFileSpan ;
4846use crate :: eval:: runtime:: inlined_frame:: InlinedFrames ;
4947use crate :: eval:: runtime:: profile:: bc:: BcProfile ;
48+ use crate :: eval:: runtime:: profile:: data:: ProfileData ;
5049use crate :: eval:: runtime:: profile:: flame:: FlameProfile ;
5150use crate :: eval:: runtime:: profile:: heap:: HeapProfile ;
5251use crate :: eval:: runtime:: profile:: heap:: HeapProfileFormat ;
@@ -301,15 +300,12 @@ impl<'v, 'a> Evaluator<'v, 'a> {
301300 /// Write a profile to a file.
302301 /// Only valid if corresponding profiler was enabled.
303302 pub fn write_profile < P : AsRef < Path > > ( & self , filename : P ) -> anyhow:: Result < ( ) > {
304- let profile = self . gen_profile ( ) ?;
305- fs:: write ( filename. as_ref ( ) , profile)
306- . with_context ( || format ! ( "writing profile to `{}`" , filename. as_ref( ) . display( ) ) ) ?;
307- Ok ( ( ) )
303+ self . gen_profile ( ) ?. write ( filename. as_ref ( ) )
308304 }
309305
310306 /// Generate profile for a given mode.
311307 /// Only valid if corresponding profiler was enabled.
312- pub fn gen_profile ( & self ) -> anyhow:: Result < String > {
308+ pub fn gen_profile ( & self ) -> anyhow:: Result < ProfileData > {
313309 let mode = match & self . profile_or_instrumentation_mode {
314310 ProfileOrInstrumentationMode :: None => {
315311 return Err ( EvaluatorError :: ProfilingNotEnabled . into ( ) ) ;
@@ -335,7 +331,9 @@ impl<'v, 'a> Evaluator<'v, 'a> {
335331 . stmt_profile
336332 . gen ( )
337333 . ok_or_else ( || EvaluatorError :: StmtProfilingNotEnabled . into ( ) ) ,
338- ProfileMode :: Bytecode | ProfileMode :: BytecodePairs => self . bc_profile . gen_csv ( ) ,
334+ ProfileMode :: Bytecode | ProfileMode :: BytecodePairs => {
335+ self . bc_profile . gen_csv ( ) . map ( ProfileData :: new)
336+ }
339337 ProfileMode :: TimeFlame => self
340338 . flame_profile
341339 . gen ( )
0 commit comments