2017 © Pedro Peláez
 

library benchmark

Benchmark - PHP Standalone Benchmark class.

image

best-served-cold/benchmark

Benchmark - PHP Standalone Benchmark class.

  • Sunday, March 12, 2017
  • by nark3d
  • Repository
  • 2 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight Latest Stable Version, (*1)

Benchmark

Install

$ composer require best-served-cold/benchmark

Usage

Call in the Benchmark and Output classes, (*2)

use BestServedCold\Benchmark\Benchmark;
use BestServedCold\Benchmark\Output;

Then benchmark a bunch of code:, (*3)

Benchmark::start();
for ($i = 0; $i <= 100; $i++ ) {
    mt_rand(1, 1000);
}
Benchmark::stop();
Output::output(Benchmark::get())->render();

Returns something like this:, (*4)

+---------------+-------------------+--------------------+
| Name          | Metric            | Value              |
+---------------+-------------------+--------------------+
| 58c4302514614 | MicroTime         | 0.0022561550140381 |
| 58c4302514614 | MemoryUsage       | 160.05 KB          |
| 58c4302514614 | DeclaredInterface | 0                  |
| 58c4302514614 | DeclaredTrait     | 2                  |
| 58c4302514614 | DefinedFunction   | 0                  |
| 58c4302514614 | DefinedConstant   | 0                  |
| 58c4302514614 | IncludedFile      | 1                  |
| 58c4302514614 | DeclaredClass     | 0                  |
| 58c4302514614 | PeakMemoryUsage   | 1.54 MB            |
+---------------+-------------------+--------------------+

As no $name argument is specified, a hashed name will be given as means of identification., (*5)

Naming benchmarks

Benchmark::reset(); // Clear existing benchmarks
Benchmark::start('bob');
$a = str_repeat('Hello', 24000);
define('FOO', 'bar');
Benchmark::stop('bob');
Benchmark::start('mary');
require_once('./SomeClass.php');
sleep(1);
Benchmark::stop('mary');

Returns something like:, (*6)

+------+-------------------+--------------------+
| Name | Metric            | Value              |
+------+-------------------+--------------------+
| bob  | MicroTime         | 0.0014297962188721 |
| bob  | MemoryUsage       | 191.77 KB          |
| bob  | DeclaredInterface | 0                  |
| bob  | DeclaredTrait     | 0                  |
| bob  | DefinedFunction   | 0                  |
| bob  | DefinedConstant   | 1                  |
| bob  | IncludedFile      | 0                  |
| bob  | DeclaredClass     | 0                  |
| bob  | PeakMemoryUsage   | 2.18 MB            |
+------+-------------------+--------------------+
| mary | MicroTime         | 1.0012910366058    |
| mary | MemoryUsage       | 75.48 KB           |
| mary | DeclaredInterface | 0                  |
| mary | DeclaredTrait     | 0                  |
| mary | DefinedFunction   | 0                  |
| mary | DefinedConstant   | 0                  |
| mary | IncludedFile      | 1                  |
| mary | DeclaredClass     | 1                  |
| mary | PeakMemoryUsage   | 2.18 MB            |
+------+-------------------+--------------------+

Specifying output interface

Benchmark::reset();
Benchmark::start('susan');
require_once('./SomeTrait.php');
Benchmark::stop('susan');
Output::output(Benchmark::get(), 'apache')->render();

Returns something like:, (*7)

Name Metric Value
susan MicroTime 0.0014090538024902
susan MemoryUsage 76.03 KB
susan DeclaredInterface
susan DeclaredTrait 1
susan DefinedFunction
susan DefinedConstant
susan IncludedFile 1
susan DeclaredClass
susan PeakMemoryUsage 2.18 MB

The Versions

12/03 2017

dev-master

9999999-dev http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance

12/03 2017

1.0.4

1.0.4.0 http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance

12/03 2017

1.0.3

1.0.3.0 http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance

12/03 2017

1.0.2

1.0.2.0 http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance

12/03 2017

1.0.1

1.0.1.0 http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance

11/03 2017

1.0.0

1.0.0.0 http://bestservedcold.com

Benchmark - PHP Standalone Benchmark class.

  Sources   Download

MIT

The Requires

 

The Development Requires

benchmark profiler best served cold peformance