PHP Classes

XBenchmark: Log time and resources during script execution

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-10 (9 months ago) RSS 2.0 feedStarStarStarStar 60%Total: 255 All time: 7,860 This week: 571Up
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 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: 215 Up7 in Spain Spain Up
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 (3)  
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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:255
This week:0
All time:7,860
This week:571Up
 User Ratings  
 
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1211