https://github.com/myaaghubi/debench
A small debug/benchmark helper for PHP
https://github.com/myaaghubi/debench
benchmark debench debug php tool
Last synced: 8 months ago
JSON representation
A small debug/benchmark helper for PHP
- Host: GitHub
- URL: https://github.com/myaaghubi/debench
- Owner: myaaghubi
- License: mit
- Created: 2024-03-24T16:19:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-29T11:18:05.000Z (over 1 year ago)
- Last Synced: 2025-01-31T09:22:04.622Z (over 1 year ago)
- Topics: benchmark, debench, debug, php, tool
- Language: PHP
- Homepage:
- Size: 1.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Debench
[](https://github.com/myaaghubi/Debench/actions/workflows/ci.yml) [](https://coveralls.io/github/myaaghubi/Debench?branch=main)  
A small and lightweight debug/benchmark helper for PHP.


# How to use
Use composer:
```shell
composer require myaaghubi/debench
```
Then have it like:
```php
namespace DEBENCH;
require __DIR__ . '/vendor/autoload.php';
// call it from your index.php after autoload
// then check the webpage with your browser
// $debench = new Debench(true, '../public', $base->get('ASSETS'));
Debench::getInstance(true, '../public', $base->get('ASSETS'));
// for enable() or minimalOnly() you can
// call them even before getInstance
Debench::enable(false);
// for dump(), info(), warning() and error() you can
// call them before getInstance too
Debench::info('let\'s use some memory');
// let's load some
$st = str_repeat("Debench!", 10000);
Debench::point('one');
Debench::dump($st);
// let's load some more
$st .= str_repeat("Debench!", 10000);
// $debench->newPoint("two");
Debench::point('two');
```
For `minimal` mode:
```php
// it is safe and secure to use
// $debench->setMinimalOnly(true);
Debench::minimalOnly(true);
```
For `production` mode
```php
// it's better to do it on initializing
//$debench = new Debench(false);
Debench::getInstance(false);
// or
Debench::enable(false);
```
For `comparison` mode
```php
// Debench::compare($func1, $func2, $tag='', $iterations=1000);
Debench::compare(function () use ($mongo) {
$mongo->find([])
}, function () use ($sql) {
$sql->exec('select ...');
});
```
# How to test
Just run:
```
./vendor/bin/phpunit
```
## License
You are allowed to use this plugin under the terms of the MIT License.
Copyright (C) 2025 Mohammad Yaaghubi