Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

v1 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

v1 #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.php_cs.cache
build
composer.lock
docs
vendor
9 changes: 5 additions & 4 deletions benchmarks/FilterOneMillionItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

class FilterOneMillionItems
{
const ONE_MILLION = 1000000;
public const ONE_MILLION = 1000000;

/**
* @Revs(10)
*/
public function benchCollectionArray()
{
$collection = Collection::from(range(0, static::ONE_MILLION));
$collection = Collection::from(\range(0, static::ONE_MILLION));

$result = $collection->filter(function ($i) {
return $i % 2 === 0;
Expand All @@ -23,7 +23,7 @@ public function benchCollectionArray()
*/
public function benchNativeArrayFilter()
{
$result = array_filter(range(0, static::ONE_MILLION), function ($i) {
$result = \array_filter(\range(0, static::ONE_MILLION), function ($i) {
return $i % 2 === 0;
});
}
Expand All @@ -33,8 +33,9 @@ public function benchNativeArrayFilter()
*/
public function benchForEachArray()
{
$items = range(0, static::ONE_MILLION);
$items = \range(0, static::ONE_MILLION);
$filtered = [];

foreach ($items as $i => $item) {
if ($i % 2 === 0) {
$filtered[$i] = $item;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/LoopOneHundredThousandItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class LoopOneHundredThousandItems
*/
public function benchCollectionArray()
{
$collection = Collection::from(range(0, 100000));
$collection = Collection::from(\range(0, 100000));
$collection->each(function ($i) {
});
}

public function benchForeachArray()
{
$array = range(0, 100000);
$array = \range(0, 100000);

foreach ($array as $i) {
}
Expand Down
11 changes: 6 additions & 5 deletions benchmarks/MapOneMillionItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

class MapOneMillionItems
{
const ONE_MILLION = 1000000;
public const ONE_MILLION = 1000000;

/**
* @Revs(10)
*/
public function benchCollectionArray()
{
$collection = Collection::from(range(0, static::ONE_MILLION));
$collection = Collection::from(\range(0, static::ONE_MILLION));

$result = $collection->map(function ($i) {
return $i * 2;
Expand All @@ -23,17 +23,18 @@ public function benchCollectionArray()
*/
public function benchNativeArrayMap()
{
$result = array_map(function ($i) {
$result = \array_map(function ($i) {
return $i * 2;
}, range(0, static::ONE_MILLION));
}, \range(0, static::ONE_MILLION));
}

/**
* @Revs(10)
*/
public function benchForEachArray()
{
$items = range(0, static::ONE_MILLION);
$items = \range(0, static::ONE_MILLION);

foreach ($items as $i => $item) {
$items[$i] = $item * 2;
}
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
}
],
"require": {
"php" : "^7.0",
"php" : "^7.2",
"narrowspark/arr" : "^2.1"
},
"require-dev": {
"narrowspark/php-cs-fixer-config" : "^2.0",
"mockery/mockery" : "^1.0",
"narrowspark/php-cs-fixer-config" : "^3.0.2",
"phpbench/phpbench" : "^0.13",
"phpunit/phpunit" : "^5.1"
"phpunit/phpunit" : "^7.2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -44,6 +43,10 @@
"dev-master" : "1.0.0-dev"
}
},
"scripts": {
"cs": "php-cs-fixer fix",
"phpstan": "phpstan analyse -c phpstan.neon -l 7 src --memory-limit=-1"
},
"minimum-stability" : "dev",
"prefer-stable" : true
}
Loading