Skip to content

pgrimaud/phpbench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPBench

Some PHP benchmarks - Very nice! WoW!

Based on phpbench/phpbench.

Installation

composer install

Usage

Run all tests

bin/bench benchmarks 

Run specific test

bin/bench benchmarks/GetFirstElementOfArray.php

Results

Get first element of array

+-------------------+---------+-------+
| subject           | mean    | diff  |
+-------------------+---------+-------+
| benchWithFirstKey | 0.048μs | 1.00x |
| benchWithCurrent  | 0.060μs | 1.27x |
| benchWithForeach  | 0.065μs | 1.36x |
| benchWithReset    | 0.107μs | 2.25x |
+-------------------+---------+-------+

Remove last element of tiny array (10 entries)

+------------------------------------+---------+-------+
| subject                            | mean    | diff  |
+------------------------------------+---------+-------+
| benchWithUnset                     | 0.117μs | 1.00x |
| benchWithArraySlice                | 0.135μs | 1.15x |
| benchWithArrayPop                  | 0.145μs | 1.24x |
| benchWithArrayReverseAndArrayShift | 0.253μs | 2.17x |
+------------------------------------+---------+-------+

Remove last element of large array (10000 entries)

+------------------------------------+----------+-------+
| subject                            | mean     | diff  |
+------------------------------------+----------+-------+
| benchWithArrayPop                  | 31.149μs | 1.00x |
| benchWithUnset                     | 32.279μs | 1.04x |
| benchWithArraySlice                | 33.904μs | 1.09x |
| benchWithArrayReverseAndArrayShift | 94.314μs | 3.03x |
+------------------------------------+----------+-------+

Create new object (thanks @nicolasbonnici)

+-------------------------------+---------+-------+
| subject                       | mean    | diff  |
+-------------------------------+---------+-------+
| benchWithArrayAndCast         | 0.086μs | 1.00x |
| benchWithAnonymousDeclaration | 0.088μs | 1.02x |
| benchWithJsonEncode           | 0.114μs | 1.32x |
| benchWithSdtClass             | 0.124μs | 1.44x |
+-------------------------------+---------+-------+

LICENSE

Licensed under the terms of the MIT License.

About

Some personal PHP benchmarks - Very nice! WoW!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published