Skip to content

Commit

Permalink
Merge pull request #2 from equip/feature/benchmarks
Browse files Browse the repository at this point in the history
Add benchmark support
  • Loading branch information
shadowhand committed Mar 21, 2016
2 parents 071a968 + cbf7d21 commit 8ec84ac
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ matrix:

before_script:
- travis_retry composer self-update
- travis_retry composer require phpunit/phpunit
- travis_retry composer require phpunit/phpunit phpbench/phpbench
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- vendor/bin/phpunit
- composer test
- composer bench

after_script:
- bash -c '[[ -f "build/logs/clover.xml" ]] && wget https://scrutinizer-ci.com/ocular.phar'
Expand Down
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 8ec84ac

Please sign in to comment.