public static void stopProfilerAndReport ( ) { profiler . stopCollecting ( ) ; // Write a report file try { // Get path from property file String path = CoreProperties . getLoader ( ) . getPropertyAsString ( VanillaDb . class . getName ( ) + ".PROFILE_OUTPUT_DIR" , System . getProperty ( "user.home" ) ) ; File out = new File ( path , System . currentTimeMillis ( ) + "_profile.txt" ) ; FileWriter wrFile = new FileWriter ( out ) ; BufferedWriter bwrFile = new BufferedWriter ( wrFile ) ; // Write Profiling Report bwrFile . write ( profiler . getTopPackages ( 30 ) ) ; bwrFile . newLine ( ) ; bwrFile . write ( profiler . getTopMethods ( 30 ) ) ; bwrFile . newLine ( ) ; bwrFile . write ( profiler . getTopLines ( 30 ) ) ; /* * I should write a more careful code here. I didn't do it, because * of the same reason above. */ bwrFile . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Stop profiler and generate report file .