dev-master
9999999-dev https://github.com/Fredyy90/BenchmarkSimple benchmark and compare class for php code
MIT
The Requires
- php >=5.3.0
code benchmark performance
Wallogit.com
2017 © Pedro PelĂĄez
Simple benchmark and compare class for php code
Simple Class to Benchmark and compare PHP-Code, (*1)
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
<?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 "
";
Simple benchmark and compare class for php code
MIT
code benchmark performance