GitXplorerGitXplorer
s

php-benchmark

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
c93d6be84c273e7d9c8b6ccc10879882b066513f

Add another example

sscottchiefbaker committed 10 months ago
Unverified
8f33e1f66b73f931bd9a318814192e48a4f229e7

Merge branch 'master' of github.com:scottchiefbaker/php-benchmark

sscottchiefbaker committed a year ago
Unverified
30802ebc984d589ec5f5f22a43596ba8a4455217

Another test

sscottchiefbaker committed a year ago
Unverified
3fa91bd92bfb5f55c2018abcdeb031dc8be2bd0b

Clean up skel

sscottchiefbaker committed a year ago
Unverified
1586a639fa55bcb1355d051a5028a82f33e2b498

New test

sscottchiefbaker committed a year ago
Unverified
452ae660b9f608dc2c1f191301a1bf579492493f

Add skel.php to make future tests simpler

sscottchiefbaker committed a year ago

README

The README file for this repository.

PHP-Benchmark

Simple library to compare the speed of PHP code snippets.

Usage:

require('benchmark.class.php');

$a = function($str) {
	return strtoupper($str);
};

$b = function($str) {
	return strtolower($str);
};

$bm = new benchmark;

// Run the benchmark on each function
// $bm->time_this(name, anonymous function, array of arguments to pass);
$bm->time_this('Convert to Uppercase',$a,array('kittens'));
$bm->time_this('Convert to Lowercase',$b,array('KITTENS'));

// Print out the summary of the benchmarks we've run
$bm->summary();

Sample text output:

PHP Version: 7.1.14

                     trim | rtrim + ltrim | find + substr |   regexp
               +-----------------------------------------------------+
          trim |      N/A |       106.32% |       595.74% |  763.28% |
 rtrim + ltrim |   94.05% |           N/A |       560.31% |  717.88% |
 find + substr |   16.79% |        17.85% |           N/A |  128.12% |
        regexp |    13.1% |        13.93% |        78.05% |      N/A |
               +-----------------------------------------------------+

          trim = 2,544,217 iterations per second
 rtrim + ltrim = 2,392,881 iterations per second
 find + substr = 427,065 iterations per second
        regexp = 333,325 iterations per second

Sample HTML output:

PHP Version: 7.1.14

  trim rtrim + ltrim find + substr regexp
trim n/a 108.76% 611.23% 782.93%
rtrim + ltrim 91.94% n/a 561.99% 719.86%
find + substr 16.36% 17.79% n/a 128.09%
regexp 12.77% 13.89% 78.07% n/a

trim = 2,603,898 iterations per second
rtrim + ltrim = 2,394,144 iterations per second
find + substr = 426,013 iterations per second
regexp = 332,585 iterations per secon