I am doing a bit of broad performance analysis within an application I maintain and I have setup an easy means to fix track the execution duration of demands, but I am not able to locate information to ensure if the will probably be satisfyingly accurate.

This seems to possess netted good quality information and I have already removed some performance issues consequently, but I am also seeing some confusing records which make me question the precision from the recorded execution time.

Must I add an explicit method call in the finish of every calling script to mark the finish of their execution or perhaps is this (rather tidy) approach while using destructor adequate?

The calling code towards the top of the asked for script:

if( file_exists('../../../bench') )
{
    require('../../../includes/classes/Bench.php');
    $Bench = new Bench;
}

Here is the course definition (reduced for clearness):

require_once('Class.php');

class Bench extends Class
{
    protected $page_log = 'bench-pages.log';
    protected $page_time_end;
    protected $page_time_start;

    public function __construct()
    {
        $this->set_page_time_start();
    }

    public function __destruct()
    {
        $this->set_page_time_end();
        $this->add_page_record();
    }

    public function add_page_record()
    {
        $line = $this->page_time_end - $this->page_time_start.','.
                base64_encode(serialize($_SERVER)).','.
                base64_encode(serialize($_GET)).','.
                base64_encode(serialize($_POST)).','.
                base64_encode(serialize($_SESSION))."\n";

        $fh = fopen( APP_ROOT . '/' . $this->page_log, 'a' );
        fwrite( $fh, $line );
    }

    public function set_page_time_end()
    {
        $this->page_time_end = microtime(true);
    }

    public function set_page_time_start()
    {
        $this->page_time_start = microtime(true);
    }
}

What you ought to do is use Xdebug. It's very simple when you arrange it and do not have to change anything regarding your code to obtain full dental coverage plans of the items required how lengthy.