Skip to content

Commit

Permalink
bench
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Nov 13, 2017
1 parent 4c1c7a9 commit 202f268
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -43,7 +43,7 @@ putenv('LC_ALL=uk_UA.UTF-8');
setlocale(LC_ALL, 'uk_UA.UTF-8');

// init database
$isoCodes = new \Sokil\IsoCodes;
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();

// get languages database
$languages = $isoCodes->getLanguages();
Expand Down Expand Up @@ -77,7 +77,7 @@ Countries

Get localized name of country by it's alpha2 code:
```php
$isoCodes = new \Sokil\IsoCodes;
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
$isoCodes->getCountries()->getByAlpha2('UA')->getLocalName();
```

Expand All @@ -89,13 +89,13 @@ $isoCodes->getCountries()->getByAlpha2('UKR')->getName();

Get localized name of country by it's numeric code:
```php
$isoCodes = new \Sokil\IsoCodes;
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
$isoCodes->getCountries()->getByAlpha2('804')->getName();
```

Get localised list of countries
```php
$isoCodes = new \Sokil\IsoCodes;
$isoCodes = new \Sokil\IsoCodes\IsoCodesFactory();
foreach($isoCodes->getCountries() as $country) {
echo $country->getLocalName();
}
19 changes: 19 additions & 0 deletions benchmarks/CountriesBench.php
@@ -0,0 +1,19 @@
<?php

namespace Sokil\IsoCodes\Databases;

use Sokil\IsoCodes\IsoCodesFactory;

class CountriesBench
{
/**
* @Warmup(1)
* @Revs(1000)
* @Iterations(2)
*/
public function benchIterator()
{
$isoCodes = new IsoCodesFactory();
$isoCodes->getCountries()->toArray();
}
}
6 changes: 4 additions & 2 deletions composer.json
Expand Up @@ -19,7 +19,7 @@
},
"autoload": {
"psr-4": {
"Sokil\\IsoCodes\\": "src/"
"Sokil\\IsoCodes\\": ["src/", "tests/", "benchmarks/"]
},
"classmap": ["stubs/"]
},
Expand All @@ -28,6 +28,8 @@
"cover": "./vendor/bin/phpunit -c ./tests/phpunit.xml --coverage-clover ./build/logs/clover.xml ./tests",
"coveralls": "./vendor/bin/coveralls -v",
"check-style": "./vendor/bin/phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src",
"fix-style": "./vendor/bin/phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src"
"fix-style": "./vendor/bin/phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src",
"bench": "phpbench run benchmarks/ --report=aggregate",
"infection": "infection"
}
}
3 changes: 3 additions & 0 deletions phpbench.json
@@ -0,0 +1,3 @@
{
"bootstrap": "vendor/autoload.php"
}

0 comments on commit 202f268

Please sign in to comment.