Download the PHP package bluetree-service/benchmark without Composer
On this page you can find all versions of the php package bluetree-service/benchmark. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bluetree-service/benchmark
More information about bluetree-service/benchmark
Files in bluetree-service/benchmark
Package benchmark
Short Description Class Benchmark libraries
License Apache-2.0
Homepage https://github.com/bluetree-service/benchmark
Informations about the package benchmark
BlueTree Service Benchmark
Documentation
Timer basic usage
- Start benchmark by execute
\Benchmark\Performance\Timer::start()
, that will launch time storage. - To measure time from start time, until some position use
::setMarker('some description')
, that will save time execution and memory usage from start, or previous marker to current position. - After we set sime markers, use
::stop()
to halt benchmark. -
Use
::calculateStats()
to get information about execution time and memory usage. - If you want to get formatted output, look down for Timer formatting output section.
Timer advanced usage
For more cleared view, we can join stats into groups, to see, how mutch time and memory use whole group. To begin measure
in group use ::startGroup('group name')
, set markers inside and use ::endGroup('group name')
with the same name to
store stats inside one group. Of course there is possibility to create nested groups.
Timer other functions
- start() can have additional boolean argument, if false, then will whole timer will be disabled
- turnOffBenchmark() allow to turn off Timer
- turnOnBenchmark() allow to turn on Timer
Timer formatting output
There are three possibilities to get formatted output. First one allow to ger output as array with formatted time, memory and percentage values. second one allow to get output formatted by Symfony Console output class. And last one allow to get output as HTML.
Pre-formatted array
After \Benchmark\Performance\Timer::stop();
execute (Timer::getFormattedOutput('raw+')
to get array with formatted
memory, time and percentage. Using raw as parameter return raw values, the same as usage of
\Benchmark\Performance\Timer::calculateStats();
Console output
After \Benchmark\Performance\Timer::stop();
execute (Timer::getFormattedOutput('shell')
to get formatted output for
console. Output will be equivalent of that:
HTML output
After \Benchmark\Performance\Timer::stop();
execute (Timer::getFormattedOutput('html')
to get formatted output for
browser. Output will be equivalent of that:
Write own output formatter
If you want to get data in you own specified format, you can apply it to method calculateStats
. This method accept
callable
type to process data array before it will be returned.
This is how it looks inside the original code: self::calculateStats([Formatter::class, 'formatValues']);
- this will
execute method formatValues
from Formatter::class
class.
Screenshots
![]()
Install via Composer
To use packages you can just download package and pace it in your code. But recommended way to use ClassBenchmark is install it via Composer. To include ClassBenchmark libraries paste into composer json:
Required for ClassBenchmark libraries (ClassKernel) will be loaded automatically.
Project description
Used conventions
- Namespaces - each library use namespaces
- PSR-4 - PSR-4 coding standard
- Composer - Composer usage to load/update libraries
Requirements
- PHP 5.4 or higher
- DOM extension enabled
Change log
All release version changes:
Change log
License
This bundle is released under the Apache 2.0 license.
Apache license