Skip to content

Commit de198f3

Browse files
committed
Some fixes and documentation
1 parent 84f1b74 commit de198f3

13 files changed

+99
-196
lines changed

README.md

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,75 @@ Documentation
1010
-
1111

1212
* [Requirements and installation](documentation/installation.md)
13-
* [Ask us to create repositories](documentation/createRepositories.md)
1413
* [Understand repositories and branches](documentation/repositoriesAndBranches.md)
15-
* [Initialize main repository branch](documentation/initializeBranch.md)
16-
* [Use ./composerUpdate.sh and not your composer](documentation/composerUpdate.md)
17-
18-
Add required features for benchmarks
14+
15+
Benchmark kit commands
16+
-
17+
18+
When you are inside benchmark kit Docker container, you can use `phpbench` to list benchmark kit commands.
19+
20+
Almost all commands accept this options:
21+
* `--skip-branch-name`: don't validate git branch name, usefull while you are in development and repositories are not created yet.
22+
* `--skip-source-code-urls`: don't validate source code urls, usefull while you are in development.
23+
* `--validate-prod`: you should not need it, it's used when we test your code before benchmarking it.
24+
25+
#1 Ask us to create repositories
26+
-
27+
28+
You can ask us to create repositories with [contact form](http://www.phpbenchmarks.com/en/contact).
29+
30+
Tell us which component and version you want to benchmark,
31+
and `your github username` to allow you to commit on this repositories.
32+
33+
We will send you an email when repositories will be created.
34+
35+
36+
#2 Start benchmark kit
37+
-
38+
39+
To start benchmark kit Docker container, you have to call `./vendor/bin/start.sh`.
40+
41+
It will ask you the directory where you code is located.
42+
You can pass this directory as parameter to this script.
43+
44+
```bash
45+
./vendor/bin/start.sh
46+
./vendor/bin/start.sh /foo/code
47+
```
48+
49+
#3 Initialize code
1950
-
2051

21-
Choose your component type (framework or template engine) and benchmark type you want to code:
52+
To make your benchmark work you will need some files into `.phpbenchmarks` directory:
53+
* `AbstractComponentConfiguration.php`: configuration of benchmarked component.
54+
* `initBenchmark.sh`: called before the benchmark to initialize everything (composer install, cache warmup etc).
55+
* `vhost.conf`: nginx virtual host configuration.
56+
* `responseBody/`: benchmark url body will be compared to files in this directory to validate it's content.
57+
58+
All this files can be created and configured with `phpbench` commands:
59+
60+
```
61+
composer:update Execute composer update for all enabled PHP versions and create composer.lock.phpX.Y
62+
63+
configure:all Call all configure commands
64+
configure:component Create .phpbenchmarks/AbstractComponentConfiguration.php and configure it
65+
configure:component:sourceCodeUrls Create .phpbenchmarks/AbstractComponentConfiguration.php and configure getSourceCodeUrls()
66+
configure:directory Create .phpbenchmarks and .phpbenchmarks/responseBody directories
67+
configure:initBenchmark Create .phpbenchmarks/initBenchmark.sh
68+
configure:responseBody Create .phpbenchmarks/responseBody files
69+
configure:vhost Create .phpbenchmarks/vhost.conf, create phpXY.benchmark.loc vhosts and reload nginx
70+
```
71+
72+
You can call `configure:all` to create all of them, or use the one your need.
73+
74+
Note the `phpbench composer:update` command. We need a `composer.lock` per PHP version,
75+
because some dependencies are installed in different versions depending on the version of PHP.
76+
Use `phpbench composer:update` to switch between PHP version, and create `composer.lock.phpX.Y`.
77+
78+
#4 Add required features for benchmarks
79+
-
80+
81+
Choose the component type and benchmark type you want to code:
2282

2383
* Framework
2484
* [Hello world benchmark](documentation/framework/helloWorld.md)
@@ -28,22 +88,24 @@ Choose your component type (framework or template engine) and benchmark type you
2888

2989
Note that `all` component benchmarks needs to bo validated to make your component appear on [phpbenchmarks.com](http://www.phpbenchmarks.com).
3090

31-
Code validation
91+
#5 Test and validate your code
3292
-
3393

34-
You can use [./codeValidation.sh](documentation/codeValidation.md) to validate your code, while you are in development or when you think it's finished.
35-
36-
Code links
37-
-
94+
Docker container provide a domain for each PHP version, from 5.6 to 7.3:
95+
* http://php56.benchmark.loc
96+
* http://php70.benchmark.loc
97+
* http://php71.benchmark.loc
98+
* http://php72.benchmark.loc
99+
* http://php73.benchmark.loc
38100

39-
To show us all features are included, you need to indicate where each feature is coded.
101+
You can use them to test your code.
40102

41-
[./codeLink.sh](documentation/codeLink.md) helps you to tell us.
103+
When you think it's ok, use `phpbench benchmark:validate` to validate it.
42104

43-
Everything is done
105+
#6 Submit your code
44106
-
45107

46-
When [./codeValidation.sh](documentation/codeValidation.md) and [./codeLink.sh](documentation/codeLink.md) say it's good,
108+
When `phpbench benchmark:validate` say it's good,
47109
you can tell us to launch benchmarks with [contact form](http://www.phpbenchmarks.com/en/contact).
48110

49111
Thank you!

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@
1212
],
1313
"require-dev": {
1414
"steevanb/docker-php-code-sniffs": "~1.0.2"
15-
}
15+
},
16+
"bin": [
17+
"start.sh",
18+
"dockerBash.sh"
19+
]
1620
}

documentation/codeLink.md

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

documentation/codeValidation.md

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

documentation/composerUpdate.md

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

documentation/createRepositories.md

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

documentation/framework/helloWorld.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Hello world benchmark
33

44
This benchmark shows the overhead cost of using a framework, instead of writing your code in PHP.
55

6-
To respect that, code should write `Hello World !` in response body, as fast as possible.
6+
To respect that, code should write `Hello World !` (yes, with space before `!`, cocorico ;)) in response body, as fast as possible.
77

88
Disable everything you can: template engine, session, database access etc.
99

@@ -16,9 +16,4 @@ Don't forget this features as to be coded in [common repository](../repositories
1616
* A controller, called by this route. [Example](https://github.com/phpbenchmarks/symfony-common/blob/symfony_4_hello-world/Controller/HelloWorldController.php).
1717
* This controller should write `Hello World !` in response body as fast as possible. [Example](https://github.com/phpbenchmarks/symfony-common/blob/symfony_4_hello-world/Controller/HelloWorldController.php#L13).
1818

19-
Validate your code
20-
-
21-
22-
When your code est terminated, you can validate it with [./codeValidation.sh](../codeValidation.md).
23-
2419
[Back to documentation index](../../README.md)

documentation/initializeBranch.md

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

documentation/installation.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ Requirements
22
-
33

44
You will need this dependencies to make it work:
5-
* Linux, to use Docker and bash scripts
5+
* Linux to use Docker and bash scripts
66
* [Docker ^18.06](https://docs.docker.com/install/)
77
* [docker-compose ^1.12](https://docs.docker.com/compose/install/)
88

99
Installation
1010
-
1111

12-
Add `phpbenchmarks/benchmark-kit` as dependency of your projet.
13-
14-
Not you have to do it in `require`, not in `require-dev`.
15-
As benchmark kit contains only bash scripts, requiring it will not affect your code until you call them manually.
16-
1712
```bash
18-
composer require phpbenchmarks/benchmark-kit ^1.0
13+
# you can install it where you want, ~/benchmarkKit used for the example
14+
mkdir ~/benchmarkKit
15+
cd ~/benchmarkKit
16+
echo '{"require": {"phpbenchmarks/benchmark-kit": "^2.0"}}' > composer.json
17+
18+
# you can use your local composer installation, of the official Docker container
19+
docker run --rm -v $(pwd):/app composer/composer update --no-dev
20+
# in Docker container, composer update is called with root user, so change permissions to current user
21+
sudo chown -R $USER:$USER vendor
1922
```
2023

2124
[Back to documentation index](../README.md)

src/Command/BenchmarkValidateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function validateForPhpVersion(string $phpVersion): self
4343
$url =
4444
'http://php'
4545
. str_replace('.', null, $phpVersion)
46-
. '.benchmark.loc'
46+
. '.benchmark.loc/'
4747
. ComponentConfiguration::getBenchmarkUrl();
4848

4949
$this

src/Command/Configure/ConfigureComponentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function () use ($phpVersion) {
7878
$this->defineVariable(
7979
'____PHPBENCHMARKS_BENCHMARK_URL____',
8080
function () {
81-
return $this->question('Benchmark url, after host?', '/benchmark/helloworld');
81+
return $this->question('Benchmark url, after host?', 'benchmark/helloworld');
8282
}
8383
);
8484

start.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function echoAsk {
2828
}
2929

3030
function defineInstallationPath {
31-
lastInstallationPathFile=$(dirname $0)/var/lastInstallationPath.sh
31+
lastInstallationPathFile="$KIT_ROOT_PATH/var/lastInstallationPath.sh"
3232
if [ ! -d "$installationPath" ]; then
3333
question="Path to your code?"
3434
if [ -f "$lastInstallationPathFile" ]; then
@@ -93,6 +93,7 @@ function addHost() {
9393
}
9494

9595
trap onExit EXIT
96+
readonly KIT_ROOT_PATH="vendor/phpbenchmarks/benchmark-kit"
9697

9798
currentAction=
9899

@@ -107,9 +108,9 @@ addHost "php71.benchmark.loc"
107108
addHost "php72.benchmark.loc"
108109
addHost "php73.benchmark.loc"
109110

110-
cd docker
111+
cd "$KIT_ROOT_PATH/docker"
111112
buildDockerImage
112113
startDockerContainer
113114
cd - 1>/dev/null
114115

115-
source dockerBash.sh
116+
source "$KIT_ROOT_PATH/dockerBash.sh"

var/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)