PHP
  Home arrow PHP arrow Page 2 - Tracking a Stack of Function Calls with the Xdebug Extension
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Tracking a Stack of Function Calls with the Xdebug Extension
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-03-16


    Table of Contents:
  • Tracking a Stack of Function Calls with the Xdebug Extension
  • Review: the xdebug_time_index() function
  • Retrieving information with the xdebug_get_function_stack() function
  • Displaying the contents of the stack of function calls

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Tracking a Stack of Function Calls with the Xdebug Extension - Review: the xdebug_time_index() function
    ( Page 2 of 4 )

    First, I'd like to quickly review the practical example developed in the preceding article of this series, in case you haven't had a chance to read that article. The example was aimed at demonstrating how to use the “xdebug_time_index()” function for building a pair of timing scripts.

    That being said, here are the two code samples that create those timing scripts. Have a look at them, please:

    (example on using the 'xdebug_time_index()' function within a procedural script)


    echo 'Starting time : '.xdebug_time_index().'<br />';

    for($i=0;$i<=3;$i++){

    // do nothing

    sleep(1);

    }

    echo 'Total script execution time : '.xdebug_time_index();


    /* displays the following


    Starting time : 0.001168966293335

    Total script execution time : 3.9993019104004

    */



    (example on using the 'xdebug_time_index()' function within an object-based script)


    class Timer{

    public function __construct(){}

    public function getTime(){

    return xdebug_time_index();

    }

    }


    $timer=new Timer();

    echo 'Starting time :'.$timer->getTime().'<br />';

    for($i=0;$i<=5;$i++){

    sleep(1);

    }

    echo 'Total script execution time :'.$timer->getTime();

    /* displays the following


    Starting time :0.0012168884277344

    Total script execution time :5.9927868843079


    */


    As you can see, the examples listed above illustrate how to use the “xdebug_time_index()” function to build a few primitive timing applications. In the first case, the function is utilized in the context of a procedural script, while the second example is a bit more interesting, since it shows how to create a basic timer class by using the function. Quite simple to grasp, right?

    Hopefully, at this point you already realized how useful the “xdebug_time_index()” function can be when it comes to calculating the execution time of a certain PHP application. So what's next? Well, as I said in the introduction, the Xdebug extension includes yet another handy function, named “xdebug_get_function_stack(),” that permits us to explore with relative ease the stack of function calls generated when a script is parsed by the PHP engine.

    Therefore, in the next section I’ll be explaining how to use this function in a concrete situation. In fact, I'll use a hands-on example to demonstrate it explicitly. This way, you can get a better idea of its actual functionality.

    To learn how this brand new example will be developed, go ahead and read the next segment. It’s only one click away.



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek