PHP Classes
elePHPant
Icontem

XBenchmark: Log time and resources during script execution

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-03-12 (4 years ago) RSS 2.0 feedStarStarStarStar 68%Total: 238 All time: 7,856 This week: 297Up
Version License PHP version Categories
xbenchmark 1.2Freeware5.2PHP 5, Logging, Performance and optim...
Description Author

This class can log time and resources used during PHP script execution until they exit without having to change the actual script code.

It appends to a log file the time a script took execute since the class was loaded, as well the maximum usage of RAM, the URL of current request and the request parameters.

The log files will be stored separated by days in a different directory per virtual host.

Configuring PHP to run the class before the script starts using the php_value auto_prepend_file configuration value and calling it for the last time from the PHP shutdown function, the class can measure the time and resource usage since the beginning until the end of execution of the script.

The class can also be started in the beginning of regular PHP scripts without requiring changes to PHP configuration values.

Innovation Award
PHP Programming Innovation award nominee
March 2015
Number 2


Prize: One downloadable copy of CodeLobster Professional
Many benchmark scripts can measure the time it takes to execute portions of a given script.

This class implements an approach that can measure the time a script takes to execute a a whole, right before it starts using the auto_prepend_file setting, until it ends using the register_shutdown_function function.

Manuel Lemos
  Performance   Level  
Name: Xavier Pérez is available for providing paid consulting. Contact Xavier Pérez .
Classes: 9 packages by
Country: Spain Spain
Age: ???
All time rank: 132726 in Spain Spain
Week rank: 677 Up24 in Spain Spain Up
Innovation award
Innovation award
Nominee: 1x

 

Details

XBenchmark

Benchmark trace & log any php, without modifying a single line of code. Usefull to trace access, monitoring run times & ram and debugging params (get / post / argv).

Install

Copy XBenchmark.php anywhere on your system.

Works either in Windows & Linux

Method 1 (For any PHP)

Modify your php.ini:

auto_prepend_file = /absolute/path/to/XBenchmark.php

Method 2 (For a virtual host)

Modify the .htaccess file under your DOCUMENT_ROOT dir, add:

php_value auto_prepend_file /absolute/path/to/XBenchmark.php

Method 3 (For only one PHP)

Modify your PHP file, put on top:

include_once "/absolute/path/to/XBenchmark.php";

In any case, verify that you have permissions on the XBENCHMARK_LOGS_DIR specified, and assign correct path to the XBenchmark.php file

Test

After apache restart (only in "Method 1" needed),

Go to any website under your apache envieronment. You will have all logs saved under XBENCHMARK_LOGS_DIR/HOST.

  Files folder image Files  
File Role Description
Plain text file logfile_example.txt Doc. Log file
Plain text file readme.md Doc. Readme
Plain text file XBenchmark.php Class Xbenchmark

 Version Control Unique User Downloads Download Rankings  
 100%
Total:238
This week:0
All time:7,856
This week:297Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:551