Skip to content

Commit 85151d3

Browse files
committed
Corrections for Benchmark kit 4
1 parent 2bfabcd commit 85151d3

17 files changed

+85
-183
lines changed

.circleci/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ jobs:
55
docker:
66
- image: phpbenchmarks/benchmark-kit:4
77
working_directory: /var/www/benchmark
8-
environment:
9-
NGINX_PORT: 80
108
steps:
119
- checkout
1210
- run:
1311
name: /var/entrypoint.sh
1412
command: /var/entrypoint.sh --nginx-as-service
1513
- run:
1614
name: "benchmark:validate"
17-
command: "/var/benchmark-kit/bin/console benchmark:validate"
15+
command: "/var/benchmark-kit/bin/console benchmark:validate:all"
1816

1917
workflows:
2018
version: '2.1'

.phpbenchmarks/Configuration.php

Lines changed: 0 additions & 75 deletions
This file was deleted.

.phpbenchmarks/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
component:
2+
id: 1
3+
benchmark:
4+
type: 3
5+
relativeUrl: /
6+
sourceCode:
7+
entryPoint: public/index.php
8+
urls:
9+
entryPoint: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php'
10+
randomizeLanguageDispatchEvent: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L51'
11+
randomizeLanguageEventListener: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/src/Translation/TranslationService.php#L11'
12+
translations: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/translations/phpbenchmarks.en_GB.php'
13+
translate: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L21'
14+
serialize: 'https://github.com/phpbenchmarks/php/tree/7.4.2_rest-api_0/public/index.php#L58'
15+
coreDependency:
16+
name: php
17+
version: 7.4.2

.phpbenchmarks/vhost.conf renamed to .phpbenchmarks/nginx/vhost.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
server {
2-
listen 80;
2+
listen ____PORT____;
33
server_name ____HOST____;
44
root ____INSTALLATION_PATH____/public;
55
location / {

.phpbenchmarks/composer/composer.lock.php7.4 renamed to .phpbenchmarks/php/7.4/composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpbenchmarks/php/7.4/php.ini

Whitespace-only changes.

.phpbenchmarks/php/7.4/preload.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$rootDir = __DIR__ . '/../../..';
6+
7+
require($rootDir . '/translations/phpbenchmarks.en.php');
8+
require($rootDir . '/translations/phpbenchmarks.en_GB.php');
9+
require($rootDir . '/translations/phpbenchmarks.fr_FR.php');
10+
require($rootDir . '/public/index.php');

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## What is www.phpbenchmarks.com?
88

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

1111
Benchmarks results are available from PHP 5.6 to latest version.
1212

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

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

21-
You can find source code links into [Configuration::getSourceCodeUrls()](.phpbenchmarks/Configuration.php).
22-
2321
## Benchmarks
2422

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

3432
## How version works?
3533

36-
We do not follow semantic version for this repository. Here is an explanation about our versioning system:
37-
38-
`W` PHP major version.
34+
We do not follow semantic version for this repository.
3935

40-
`X` PHP minor version.
36+
Here is an explanation about our versioning system:
4137

42-
`Y` PHP patch version.
38+
`X.Y.Z_benchmark-slug_W`
4339

44-
`Z` Benchmark type: `1`: Hello world, `3`: REST API, `6` JSON serialization of Hello world, `7` Small JSON serialization, `8` Big JSON serialization.
40+
* `X`: PHP major version.
41+
* `Y`: PHP minor version.
42+
* `Z`: PHP patch version.
43+
* `benchmark-slug`: slug of the benchmark, list available on [documentation page](http://www.phpbenchmarks.com/en/documentation).
44+
* `W`: benchmark version

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
},
1010
"require": {
11-
"php": "7.4.0",
11+
"php": "7.4.2",
1212
"ext-json": "*",
1313
"phpbenchmarks/benchmark-rest-data": "1.1.0"
1414
}

public/index.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,57 @@
22

33
declare(strict_types=1);
44

5-
use App\{
6-
ArrayEncoder\UserArrayEncoder,
7-
Translation\TranslationService
5+
use App\Translation\TranslationService;
6+
use PhpBenchmarksRestData\{
7+
Comment,
8+
CommentType,
9+
Service,
10+
User
811
};
9-
use PhpBenchmarksRestData\Service;
1012

11-
require('../vendor/autoload.php');
13+
require(__DIR__ . '/../vendor/autoload.php');
14+
15+
function encodeUser(User $user): array
16+
{
17+
return [
18+
'id' => $user->getId(),
19+
'login' => $user->getLogin(),
20+
'createdAt' => $user->getCreatedAt()->format('Y-m-d H:i:s'),
21+
'translated' => TranslationService::getTranslation('translated.1000'),
22+
'comments' => encodeComments($user->getComments())
23+
];
24+
}
25+
26+
/** @param Comment[] $comments */
27+
function encodeComments(array $comments): array
28+
{
29+
$return = [];
30+
foreach ($comments as $comment) {
31+
$return[] = [
32+
'id' => $comment->getId(),
33+
'message' => $comment->getMessage(),
34+
'translated' => TranslationService::getTranslation('translated.2000'),
35+
'type' => encodeType($comment->getType())
36+
];
37+
}
38+
39+
return $return;
40+
}
41+
42+
function encodeType(CommentType $type): array
43+
{
44+
return [
45+
'id' => $type->getId(),
46+
'name' => $type->getName(),
47+
'translated' => TranslationService::getTranslation('translated.3000')
48+
];
49+
}
1250

1351
TranslationService::loadTranslations();
1452

15-
$userEncoder = new UserArrayEncoder();
1653
$data = [];
1754
foreach (Service::getUsers() as $user) {
18-
$data[] = $userEncoder->encode($user);
55+
$data[] = encodeUser($user);
1956
}
2057

2158
echo json_encode($data);
22-
23-
// require phpbenchmarks stats.php here when needed

src/ArrayEncoder/CommentArrayEncoder.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/ArrayEncoder/CommentTypeArrayEncoder.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/ArrayEncoder/UserArrayEncoder.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)