Adventure,PHP,framework,page controller,front controller,pattern,object orientated design,software,development,reusability,uml,tutorial,benchmark,brilliant performance,

Search:    
Downloads  |  SVN!  |  Roadmap  |  Forum!  |  Bugtracking  |  Guestbook  |  Backlinks!  |  References!  |  Sitemap  |  Impress  
 
Deutsch | English Adventure PHP Framework  Bookmark @ Technorati Bookmark @ del.icio.us Bookmark @ Mr. Wong Bookmark @ Simpy Bookmark @ Google Bookmark @ Digg.com Adventure PHP Framework Print page 004-Benchmark

Benchmark

Rank article:
This article has not yet been ranked. Vote this article first of all!
Performance is am extremely important topic on web applications. No visitor is likely to wait longer than 10 seconds to see a web page. For this reason a benchmark component was introduced to this framework. With the benchmarkTimer component is is easy to controll the performance of an application or just a single module during development. The component measures all relevant parts by setting mesuring points within application parts and contains methods to display the process tree of the applications performance values. The page and front controller implementations already have included a lot of important measuring points to guarantee accurate performance tracking out-of-the-box. In example, the performance of each document controller is recorded by default.


1. Benchmarker practice

Benchmarking applications or parts of an application is quite easy. To measure a particural part of the code, the follwoing code must be introduced to the program:
  // start timer
  
$T = &Singleton::getInstance('benchmarkTimer');
  
$T->start('MyEvent');

  
//
  // code to be benchmarked
  //

  // stop timer
  
$T->stop('MyEvent'); 
Please note, that the benchmarkTimer must always be instanciated singleton style, because all timing information have to be stored in a single instance of the benchmarkTimer to generate a proper process tree. If this is fact is not kept in mind, benchmark information might be lost. Futher, the scope of applications must be considered. This means, that breakpoints throughout functions or classes determine, that the instance of the benchmarkTimer must be fetched by using the Singleton class every time start() or stop() is called. In such situations, the following code can be used:
  // start timer
  
$T = &Singleton::getInstance('benchmarkTimer');
  
$T->start('MyEvent');

  
//
  // code to be benachmarked
  //

  // stop timer
  
$T = &Singleton::getInstance('benchmarkTimer');
  
$T->stop('MyEvent'); 
In most situations, this case is not necessary.


2. Benchmark reports

Due to the fact, that the present framework is written to operate in the so called postback mode, the developer is able to easily integrate benchmark reporting in the central bootstrap file (mostly index.php). In the majority of cases it is adequate to place
  $T = &Singleton::getInstance('benchmarkTimer');
  echo 
$T->createReport(); 
at the end of the index.php file. If it is desired to not display benchmark information in the live system you might place the follwing code at the bottom of the index.php file:
   if(isset($_REQUEST['benchmarkreport'])){
      if(
$_REQUEST['benchmarkreport'] == 'true'){
         
$T = &Singleton::getInstance('benchmarkTimer');
         echo 
$T->createReport();
       
// end if
      
}
    
// end if
   
This makes it possible to display benchmark information on demand by adding the parameter benchmarkreport=true to the current URL. In case of URL rewriting, the parameter must be rewrited to /benchmarkreport/true or /~/benchmarkreport/true for use in frontcontroller applications. If this parameter is present the following report will be displayed at the end of the HTML page:

benchmark report process tree
To view a live benchmark please click here.


Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.


There are no comments belonging to this article.



Powered by WebRing.