vesic/benchmark

一个简单的工具,用于测量您的执行时间。

0.0.1 2017-05-17 13:49 UTC

This package is not auto-updated.

Last update: 2024-09-29 03:10:55 UTC


README

基准测试您的代码

安装

composer require vesic/benchmark

基本用法

require __DIR__ . '/vendor/autoload.php';

use Vesic\Benchmark\Benchmark;

$benchmark = new Benchmark;

$bencmark->run(function() {
    for ($i=0; $i<1e6; $i++) { }
});

function yourFunctionToMeasure() {
    // expensive computing
}

$benchmark->run('yourFunctionToMeasure');

function functionWithParams($param) {
    for ($i=0; $i<$param; $i++) { }
}

$benchmark->run('functionWithParams', 1e6);

输出

Your code performance:
Time - 0.017. Memory - 356.75 kb