2017 © Pedro Peláez
 

console simple-benchmark

PHP Simple Benchmark framework

image

asika/simple-benchmark

PHP Simple Benchmark framework

  • Saturday, June 6, 2015
  • by asika32764
  • Repository
  • 1 Watchers
  • 4 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP Simple Benchmark CLI

Installation via Composer

``` bash composer global require asika/simple-benchmark, (*1)


## Getting Started Type `benchmark` or `sb` in terminal. ``` bash sb

The output will be:, (*2)

PHP Simple Benchmark Framework - version: 2.0.0-beta
------------------------------------------------------------

[sb Help]

Help of Simple Benchmark.

Usage:
  sb <command> [option]


Options:

  -h | --help       Display this help message.
  -q | --quiet      Do not output any message.
  -v | --verbose    Increase the verbosity of messages.
  --ansi            Set 'off' to suppress ANSI colors on unsupported terminals.

Commands:

  run       Run benchmark
  create    Create a task file.

Use `benchmark create TaskName` to generate a new task sample file to /tasks folder.

Use `benchmark run TaskFile.php [times]` to run benchmark

Create a Task File

sb create TaskName

A file named TaskName.php will be generated to current folder., (*3)

Open TaskName.php you will see:, (*4)

<?php

/** @var \SimpleBenchmark\Benchmark $benchmark */

You can do your benchmark by addTask()., (*5)

<?php

/** @var \SimpleBenchmark\Benchmark $benchmark */
$benchmark->addTask('task1-md5', function() {
    md5(uniqid());
});

$benchmark->addTask('task2-sha1', function() {
    sha1(uniqid());
});

Run Benchmark

Run benchmark by this command:, (*6)

``` bash sb run TaskName.php, (*7)


The output will be:

Benchmark Result

Run 10,000 times, (*8)

task1-md5: - Time: 0.0104s - Memory: 2048kb, (*9)

task2-sha1: - Time: 0.0101s - Memory: 2048kb, (*10)


You can set times (Default is 10000) at second argument: ``` bash php benchmark run TaskName.php 15000

The Versions