enderlab/middle-earth-benchmark

Benchmark for middleware app

1.0.0 2018-01-02 16:55 UTC

This package is not auto-updated.

Last update: 2021-11-27 14:01:55 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads License

Get started

<?php
use \EnderLab\BenchmarkMiddleware;

$app->pipe(BenchmarkMiddleware::getInstance(
    BenchmarkMiddleware::START_TAG,
    [
        'benchmark.time.format'     => [
            'format'                => TimeFormatter::SECOND,
            'precision'             => 2
        ],
        'benchmark.date.format'     => 'Y-m-d',
        'benchmark.datetime.format' => 'Y-m-d H:i:s',
        'benchmark.byte.precision'  => 2,
        'benchmark.logger'          => [
            'instance'              => new Logger('test'), /* LoggerInterface default null */
            'log_level'             => LogLevel::DEBUG     /* default LogLevel::DEBUG */
        ],
        'benchmark.formatter'       => [
            'instance'              => 'EnderLab\\Benchmark\\Formatter\\DefaultMessageFormatter',
            'template'              => '{{{DATETIME}}} - time : {{{TIME}}} - memory : {{{MEMORY}}} (peak {{{MEMORY_PEAK}}})'
        ]
    ]
));
$app->pipe(/* Other middleware */);
$app->pipe(BenchmarkMiddleware::getInstance('FLAG1'));
$app->pipe(/* Other middleware */);
$app->pipe(/* Other middleware */);
$app->pipe(BenchmarkMiddleware::getInstance(
    BenchmarkMiddleware::END_TAG
));