This profiler is intended to be used to identify areas of code that could be optimised in order to improve overall performance of an application. Typically I identify the areas of concern in an application and place profile timers around those sections and focus down to add timers around the areas that are taking the most time and look for ways to optimise those particular areas. The items with the highest percentage time spent are usually the ones that can give the biggest improvements.
Perform profiling to provide the following information
include_once( 'profiler.inc');
$prof = new Profiler( profile_flag, trace_flag );
$prof->startTimer( "timer_name", "Description" );
$prof->stopTimer( "timer_name" );
$prof->printTimers( flag );
If a profile timer is started in a function, it must be stopped prior to exiting that function in order to ensure integrity of the output information.
include_once('profiler.inc'); $prof = new Profiler( true ); // Output the profile information but no trace $prof->startTimer( "initialise" ); initialise_routine(); $prof->stopTimer( "initialise" ); $prof->startTimer( "main_loop" ); while( $record=get_record() ){ print_record( $record ); } $prof->stopTimer( "main_loop" ); $prof->printTimers( true ); function get_record() { global $prof; $prof->startTimer( "get_record" ); // Routine to get the record information $prof->stopTimer( "get_record" ); } function print_record( $record ) { global $prof; // print header information $prof->startTimer( "main_print_record" ); // main print processing $prof->stopTimer( "main_print_record" ); }
If you make any improvements to the code, or just find it useful in helping you optimise the performance of your applications I would appreciate you dropping a note.
© Copyright 2002 Carl Taylor