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 (3 days ago) RSS 2.0 feedStarStarStarStar 68%Total: 254 This week: 4All time: 7,851 This week: 102Up
Version License PHP version Categories
xbenchmark 1.11Freeware5.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
Picture of Xavier Pérez
  Performance   Level  
Name: Xavier Pérez <contact>
Classes: 9 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 1x

Documentation

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:254
This week:4
All time:7,851
This week:102Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:554