Skip to content

Commit

Permalink
Add benchmark support
Browse files Browse the repository at this point in the history
In order to verify changes to functions that might affect performance.

Refs #1
  • Loading branch information
shadowhand committed Mar 21, 2016
1 parent 071a968 commit 1106e45
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 1 deletion.
123 changes: 123 additions & 0 deletions benchmarks/ArrayBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace Equip;

class ArrayBench
{
public function benchHead()
{
return \Equip\head($this->words());
}

public function benchTail()
{
return \Equip\tail($this->words());
}

private function words()
{
// 100 random words
return [
'B-G',
'Elavil',
'Gal',
'Heilbronn',
'Jawing',
'Northumbria',
'Polycarp',
'Suyog',
'Thessalians',
'Yemenis',
'adheres',
'anacardic',
'anastasis',
'arised',
'averseness',
'awright',
'bandgaps',
'bareboat',
'beader',
'bearishness',
'boxlike',
'buddha',
'chain-bearer',
'chartists',
'clickjack',
'cogence',
'colorways',
'conundrums',
'correlate',
'cultist',
'directum',
'disparity',
'dribble',
'earth-closet',
'embank',
'ethnographically',
'evokers',
'exclaimed',
'favela',
'foodist',
'grenadilla',
'gunning',
'hearthrug',
'humpy',
'indels',
'indeterminant',
'inelastic',
'innateness',
'intering',
'interlay',
'ire',
'izar',
'jaden',
'jest',
'joshing',
'leader',
'leave-taking',
'levitical',
'liveryman',
'loggias',
'lubricous',
'luxuria',
'main-hatch',
'mealie',
'minigolf',
'misgives',
'moneyspinning',
'nanomachine',
'narrativized',
'nepetalactone',
'omosternum',
'onry',
'oppidans',
'outproduced',
'palpal',
'parallelled',
'paresseuse',
'phlebotomy',
'poignant',
'poinsettias',
'psychedelia',
'redoute',
'saxhorn',
'schottische',
'semifluid',
'sheepishness',
'someways',
'striped',
'thessalonica',
'ticca',
'timekiller',
'typosquatters',
'unclenching',
'undersupplying',
'unforeseeable',
'unreckonable',
'untaxed',
'ushers',
'vivers',
'whf'
];
}
}
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
},
"require-dev": {
},
"suggest": {
"phpunit/phpunit": "Install globally to run unit tests",
"phpbench/phpbench": "Install globally to run benchmarks"
},
"autoload": {
"files": [
"src/array.php"
]
},
"autoload-dev": {
"psr-4": {
"Equip\\as\\": "tests/"
"Equip\\Assist\\": "tests/"
}
},
"scripts": {
"bench": "phpbench run --report=aggregate --revs=100 --iterations=5",
"test": "phpunit"
}
}
4 changes: 4 additions & 0 deletions phpbench.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bootstrap": "vendor/autoload.php",
"path": "benchmarks"
}

0 comments on commit 1106e45

Please sign in to comment.