PHP Classes

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
2024-01-10 (1 month ago) RSS 2.0 feedStarStarStarStar 68%Total: 254 All time: 7,852 This week: 91Up
Version License PHP version Categories
xbenchmark 1.11Freeware5.2PHP 5, Logging, Performance and optim...


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
Picture of Xavier Pérez
  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: 132727 in Spain Spain
Week rank: 349 Up16 in Spain Spain Up
Innovation award
Innovation award
Nominee: 1x



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


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


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 Doc. Readme
Plain text file XBenchmark.php Class Xbenchmark

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,852
This week:91Up
 User Ratings  
 All time