-
-
Save barryvdh/0867ee38e20f82ef443a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tests | |
composer.lock | |
composer.phar | |
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ArrayTest; | |
use Athletic\AthleticEvent; | |
class ArrayMergeEvent extends AthleticEvent | |
{ | |
private $globals = []; | |
private $context = []; | |
private $chunkLengthGlobals = 10; | |
private $chunkLengthContext = 100; | |
private $overlap = 0.2; | |
public function setUp() | |
{ | |
for ($i = 0; $i < $this->chunkLengthGlobals; $i += 1) { | |
$this->globals['index' . $i] = $i; | |
} | |
$startContext = round($this->chunkLengthGlobals - ($this->overlap * $this->chunkLengthGlobals)); | |
for ($i = 0; $i < $this->chunkLengthContext; $i += 1) { | |
$this->context['index' . ($startContext + $i)] = $i; | |
} | |
} | |
protected function getGlobals() | |
{ | |
return $this->globals; | |
} | |
/** | |
* @baseline | |
* @iterations 1000 | |
* @group classmaps-performance | |
* | |
* @return mixed | |
*/ | |
public function arrayForeach() | |
{ | |
$context = $this->context; | |
foreach ($this->getGlobals() as $key => $value) { | |
if (!array_key_exists($key, $context)) { | |
$context[$key] = $value; | |
} | |
} | |
return $context; | |
} | |
/** | |
* @iterations 1000 | |
* @group classmaps-performance | |
* | |
* @return mixed | |
*/ | |
public function arraySum() | |
{ | |
$context = $this->context; | |
return $context + $this->getGlobals(); | |
} | |
/** | |
* | |
* @iterations 1000 | |
* @group classmaps-performance | |
* | |
* @return mixed | |
*/ | |
public function arrayMerge() | |
{ | |
$context = $this->context; | |
return array_merge($this->getGlobals(), $context); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"php": ">=5.4", | |
"athletic/athletic": "~0.1.7" | |
}, | |
"autoload": { | |
"classmap": [ | |
"tests/" | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP 5.4.17 (cli) (built: Jul 12 2013 21:18:57) | |
Copyright (c) 1997-2013 The PHP Group | |
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies | |
10 globals, 10 context, 20% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000047523975] [210,420.10736] | |
arraySum : [1,000 ] [0.0000012602806] [793,474.08248] [26.52%] | |
arrayMerge : [1,000 ] [0.0000029742718] [336,216.75351] [62.58%] | |
10 globals, 10 context, 100% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000033602715] [297,595.00497] | |
arraySum : [1,000 ] [0.0000010020733] [997,931.00167] [29.82%] | |
arrayMerge : [1,000 ] [0.0000025753975] [388,289.57600] [76.64%] | |
10 globals, 100 context, 20% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000083165169] [120,242.64664] | |
arraySum : [1,000 ] [0.0000047922134] [208,671.84080] [57.62%] | |
arrayMerge : [1,000 ] [0.0000110158920] [90,777.94130] [132.46%] | |
10 globals, 100 context, 100% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000034246445] [292,001.11390] | |
arraySum : [1,000 ] [0.0000047318935] [211,331.88895] [138.17%] | |
arrayMerge : [1,000 ] [0.0000112292767] [89,052.93106] [327.90%] | |
100 globals, 10 context, 20% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000350146294] [28,559.49122] | |
arraySum : [1,000 ] [0.0000053291321] [187,647.81675] [15.22%] | |
arrayMerge : [1,000 ] [0.0000110883713] [90,184.57040] [31.67%] | |
100 globals, 100 context, 20% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000374169350] [26,725.86627] | |
arraySum : [1,000 ] [0.0000085887909] [116,430.82390] [22.95%] | |
arrayMerge : [1,000 ] [0.0000202937126] [49,276.34578] [54.24%] | |
20 globals, 1000 context, 90% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000520675182] [19,205.83185] | |
arraySum : [1,000 ] [0.0000454032421] [22,024.85888] [87.20%] | |
arrayMerge : [1,000 ] [0.0001165008545] [8,583.62803] [223.75%] | |
20 globals, 1000 context, 100% overlap | |
Method Name Iterations Average Time Ops/s Relative | |
------------------------------ ---------- ------------ -------------- --------- --------- | |
arrayForeach : [Baseline] [1,000 ] [0.0000067317486] [148,549.81406] | |
arraySum : [1,000 ] [0.0000466761589] [21,424.21363] [693.37%] | |
arrayMerge : [1,000 ] [0.0001171631813] [8,535.10453] [1,740.46%] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
mkdir tests | |
cp ArrayMergeEvent.php tests/ | |
composer install | |
php ./vendor/bin/athletic -p ./tests -b ./vendor/autoload.php -f GroupedFormatter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment