Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark support #2

Merged
merged 1 commit into from
Mar 21, 2016
Merged
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
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"
}