2017 © Pedro PelĂĄez
 

library benchmark

Simple benchmark and compare class for php code

image

fredyy90/benchmark

Simple benchmark and compare class for php code

  • Thursday, March 13, 2014
  • by Fredyy90
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Benchmark

Simple Class to Benchmark and compare PHP-Code, (*1)

Installation

To install LTSV-Serializer with Composer just add the following to your composer.json file:, (*2)

// composer.json
{
    // ...
    require: {
        // ...
        "fredyy90/Benchmark": "dev-master"
    }
}

Then, you can install the new dependencies by running Composer’s update command from the directory where your composer.json file is located:, (*3)

# install
$ php composer.phar install
# update
$ php composer.phar update fredyy90/Benchmark

# or you can simply execute composer command if you set composer command to
# your PATH environment variable
$ composer install
$ composer update fredyy90/Benchmark

Packagist page for this library is https://packagist.org/packages/fredyy90/Benchmark, (*4)

Or you can use git clone, (*5)

# HTTP
$ git clone https://github.com/fredyy90/Benchmark.git
# SSH
$ git clone git@github.com:fredyy90/Benchmark.git

Usage

<?php

use \Fredyy90\Benchmark as Benchmark;

$benchmark = new Benchmark();

$benchmark->time( 'strtr', function () {

    $replace_array = array("%time%" => 'time', "%date%" => 'date');
    $string = "am %date% um %time%";

    $string = strtr($string, $replace_array);

}, true);

$benchmark->time( 'str_replace foreach', function () {

    $replace_array = array("%time%" => 'time', "%date%" => 'date');
    $string = "am %date% um %time%";

    foreach($replace_array as $key=>$value) $string = str_replace($key,$value,$string);

}, true);


echo $benchmark->get_results_table();
echo "

";
var_dump($benchmark->get_results());
var_dump($benchmark->get_extended_results());
echo "
";

The Versions

13/03 2014

dev-master

9999999-dev https://github.com/Fredyy90/Benchmark

Simple benchmark and compare class for php code

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

code benchmark performance