PHP
  Home arrow PHP arrow Page 4 - Benchmarking 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

Benchmarking with the Xdebug Extension
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2009-03-09


    Table of Contents:
  • Benchmarking with the Xdebug Extension
  • Review: tracking program flow with the Xdebug extension
  • Benchmarking PHP applications with the X-debug extension
  • Extending the use of the xdebug_time_index() function

  • 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


    Benchmarking with the Xdebug Extension - Extending the use of the xdebug_time_index() function
    ( Page 4 of 4 )

    In the section that you just read, I explained how to use the “xdebug_time_index()” function, to create a simple procedural timing script. However, it’s also feasible to take advantage of the intrinsic capabilities of this function to build a timer class.

    Want to see how this class can be built in a few easy steps? Examine the following code sample, which defines a primitive “Timer” class that obviously uses the “xdebug_time_index()” function as its workhorse. Here it is:

    class Timer{

    public function __construct(){}

    public function getTime(){

    return xdebug_time_index();

    }

    }


    Indeed, the above “Timer” class doesn’t bear any further discussion. It only implements a single method called “getTime(),” which behaves as a wrapper for the “xdebug_time_index()” function. That’s all.

    It would, however, be pretty interesting to see how this class can be used for timing a simple application. Thus, below I coded a final hands-on example that utilizes the previous timing class for calculating the total execution time of a basic script. Here it is:

    $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


    */


    Here you have it. Now that you’ve seen for yourself how simple it is to build a timer class using the “xdebug_time_index()” function, hopefully this will fire up your own creativity, and you’ll start building your own benchmarking scripts.

    Final thoughts

    In this sixth episode of the series, I walked you through using the “xdebug_time_index()” function that comes with the X-debug extension, to perform basic benchmarking on several PHP scripts. Undeniably, the utilization of this function is pretty intuitive, so in theory you shouldn’t have major problems using it for timing your own PHP programs.

    However, this series still has a final installment, in which you’ll learn how to employ another handy function of the X-debug library. It's called “xdebug_get_function_stack(),” and it will be utilized for exploring the stack of function calls generated by the PHP engine during the execution of a script.

    Now that you’ve been warned about the subject of the final article of this series, you won’t want to miss it!



     
     
    >>> 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