2017 © Pedro PelĂĄez
 

library php-benchmark

Tool to compare different functions in PHP

image

lavoiesl/php-benchmark

Tool to compare different functions in PHP

  • Monday, December 18, 2017
  • by lavoiesl
  • Repository
  • 1 Watchers
  • 93 Stars
  • 12,101 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

PHP Benchmark

Tool to compare different functions in PHP, (*1)

Install

Via Composer, (*2)

composer require lavoiesl/php-benchmark

Usage

add('md5',   function() { return md5('test');   });
$benchmark->add('sha1',  function() { return sha1('test');  });

$benchmark->run();
?>

You can run $benchmark->run(false) to get results without any output, (*3)

Notes about memory usage

Memory usage is monitored using register_tick_function but this does not do a good job at analysing small statements since the memory gets cleaned too quickly., (*4)

A simple trick is the return the value, the AbstractTest stores it temporarily., (*5)

To ensure proper tick analysis, use declare(ticks = 1); as early as possible., (*6)

See the memory test., (*7)

Output

Running tests 3000 times.
Testing 2/2 : sha1

Test       Time   Time (%)   Memory   Memory (%)
md5     1304 ms                 0 B
sha1    2077 ms       59 %      0 B

Optimal test count guessing

By default, Benchmark will try to find an optimal number of runs so that each test takes a maximum of 2 seconds., (*8)

You can change this by forcing it with $benchmark->setCount($n) or change the time with $benchmark->guessCount($max_seconds)., (*9)

Writing custom tests

You can extend AbstractTest and provide your own wrapper., (*10)

For an example of this, see the command test and the corresponding class., (*11)

A full example can be seen here: https://github.com/lavoiesl/php-cache-comparison, (*12)

The Versions

18/12 2017

dev-master

9999999-dev

Tool to compare different functions in PHP

  Sources   Download

MIT

22/03 2014

v1.4

1.4.0.0

Tool to compare different functions in PHP

  Sources   Download

MIT

06/12 2013

v1.3.2

1.3.2.0

Tool to compare different functions in PHP

  Sources   Download

MIT

05/12 2013

v1.3.1

1.3.1.0

Tool to compare different functions in PHP

  Sources   Download

MIT

05/12 2013

v1.3

1.3.0.0

Tool to compare different functions in PHP

  Sources   Download

MIT

04/12 2013

v1.2.1

1.2.1.0

Tool to compare different functions in PHP

  Sources   Download

MIT

28/11 2013

v1.2

1.2.0.0

Tool to compare different functions in PHP

  Sources   Download

MIT

12/08 2013

v1.1

1.1.0.0

Tool to compare different functions in PHP

  Sources   Download

MIT

12/08 2013

v1.0

1.0.0.0

Tool to compare different functions in PHP

  Sources   Download

MIT