Skip to content

Commit

Permalink
Corrections for Benchmark kit 4
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed Feb 14, 2020
1 parent 2bfabcd commit 85151d3
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 183 deletions.
4 changes: 1 addition & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ jobs:
docker:
- image: phpbenchmarks/benchmark-kit:4
working_directory: /var/www/benchmark
environment:
NGINX_PORT: 80
steps:
- checkout
- run:
name: /var/entrypoint.sh
command: /var/entrypoint.sh --nginx-as-service
- run:
name: "benchmark:validate"
command: "/var/benchmark-kit/bin/console benchmark:validate"
command: "/var/benchmark-kit/bin/console benchmark:validate:all"

workflows:
version: '2.1'
Expand Down
75 changes: 0 additions & 75 deletions .phpbenchmarks/Configuration.php

This file was deleted.

17 changes: 17 additions & 0 deletions .phpbenchmarks/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
component:
id: 1
benchmark:
type: 3
relativeUrl: /
sourceCode:
entryPoint: public/index.php
urls:
entryPoint: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php'
randomizeLanguageDispatchEvent: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L51'
randomizeLanguageEventListener: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/src/Translation/TranslationService.php#L11'
translations: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/translations/phpbenchmarks.en_GB.php'
translate: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L21'
serialize: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L58'
coreDependency:
name: php
version: 7.4.2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80;
listen ____PORT____;
server_name ____HOST____;
root ____INSTALLATION_PATH____/public;
location / {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Empty file added .phpbenchmarks/php/7.4/php.ini
Empty file.
10 changes: 10 additions & 0 deletions .phpbenchmarks/php/7.4/preload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

$rootDir = __DIR__ . '/../../..';

require($rootDir . '/translations/phpbenchmarks.en.php');
require($rootDir . '/translations/phpbenchmarks.en_GB.php');
require($rootDir . '/translations/phpbenchmarks.fr_FR.php');
require($rootDir . '/public/index.php');
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## What is www.phpbenchmarks.com?

You will find lot of benchmarks for PHP frameworks, template engines and JSON serializers on [phpbenchmarks.com](http://www.phpbenchmarks.com).
You will find a lot of benchmarks for PHP and PHP libraries on [phpbenchmarks.com](http://www.phpbenchmarks.com).

Benchmarks results are available from PHP 5.6 to latest version.

Expand All @@ -18,8 +18,6 @@ It contains PHP benchmark code.

Switch branch to select version and benchmark you want to see.

You can find source code links into [Configuration::getSourceCodeUrls()](.phpbenchmarks/Configuration.php).

## Benchmarks

You can find PHP 7.4 benchmarks results on
Expand All @@ -33,12 +31,14 @@ Go to [community page](http://www.phpbenchmarks.com/en/community) to see the Hal

## How version works?

We do not follow semantic version for this repository. Here is an explanation about our versioning system:

`W` PHP major version.
We do not follow semantic version for this repository.

`X` PHP minor version.
Here is an explanation about our versioning system:

`Y` PHP patch version.
`X.Y.Z_benchmark-slug_W`

`Z` Benchmark type: `1`: Hello world, `3`: REST API, `6` JSON serialization of Hello world, `7` Small JSON serialization, `8` Big JSON serialization.
* `X`: PHP major version.
* `Y`: PHP minor version.
* `Z`: PHP patch version.
* `benchmark-slug`: slug of the benchmark, list available on [documentation page](http://www.phpbenchmarks.com/en/documentation).
* `W`: benchmark version
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
},
"require": {
"php": "7.4.0",
"php": "7.4.2",
"ext-json": "*",
"phpbenchmarks/benchmark-rest-data": "1.1.0"
}
Expand Down
53 changes: 44 additions & 9 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,57 @@

declare(strict_types=1);

use App\{
ArrayEncoder\UserArrayEncoder,
Translation\TranslationService
use App\Translation\TranslationService;
use PhpBenchmarksRestData\{
Comment,
CommentType,
Service,
User
};
use PhpBenchmarksRestData\Service;

require('../vendor/autoload.php');
require(__DIR__ . '/../vendor/autoload.php');

function encodeUser(User $user): array
{
return [
'id' => $user->getId(),
'login' => $user->getLogin(),
'createdAt' => $user->getCreatedAt()->format('Y-m-d H:i:s'),
'translated' => TranslationService::getTranslation('translated.1000'),
'comments' => encodeComments($user->getComments())
];
}

/** @param Comment[] $comments */
function encodeComments(array $comments): array
{
$return = [];
foreach ($comments as $comment) {
$return[] = [
'id' => $comment->getId(),
'message' => $comment->getMessage(),
'translated' => TranslationService::getTranslation('translated.2000'),
'type' => encodeType($comment->getType())
];
}

return $return;
}

function encodeType(CommentType $type): array
{
return [
'id' => $type->getId(),
'name' => $type->getName(),
'translated' => TranslationService::getTranslation('translated.3000')
];
}

TranslationService::loadTranslations();

$userEncoder = new UserArrayEncoder();
$data = [];
foreach (Service::getUsers() as $user) {
$data[] = $userEncoder->encode($user);
$data[] = encodeUser($user);
}

echo json_encode($data);

// require phpbenchmarks stats.php here when needed
28 changes: 0 additions & 28 deletions src/ArrayEncoder/CommentArrayEncoder.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/ArrayEncoder/CommentTypeArrayEncoder.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/ArrayEncoder/UserArrayEncoder.php

This file was deleted.

0 comments on commit 85151d3

Please sign in to comment.