-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PHPBench tool and first benchmark example (#581)
- Loading branch information
Showing
24 changed files
with
1,877 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Benchmark History Tag | ||
|
||
on: | ||
push: | ||
branches: [ 1.x ] | ||
|
||
jobs: | ||
benchmark-tag: | ||
name: "Benchmark History Tag" | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dependencies: | ||
- "locked" | ||
php-version: | ||
- "8.1" | ||
operating-system: | ||
- "ubuntu-latest" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
|
||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: none | ||
tools: composer:v2 | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
|
||
- name: "Get Composer Cache Directory" | ||
id: composer-cache | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: "Cache Composer dependencies" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "${{ steps.composer-cache.outputs.dir }}" | ||
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" | ||
restore-keys: | | ||
php-${{ matrix.php-version }}-locked-composer- | ||
- name: "Install locked dependencies" | ||
run: "composer install --no-interaction --no-progress" | ||
|
||
- name: "Cache PHPBench reports" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "var/phpbench" | ||
key: "php-${{ matrix.php-version }}-phpbench" | ||
restore-keys: | | ||
php-${{ matrix.php-version }}-phpbench- | ||
- name: "Benchmark Tag" | ||
run: "composer test:benchmark -- --tag=original --progress=plain" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Benchmark Suite | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
benchmark: | ||
name: "Benchmark" | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dependencies: | ||
- "locked" | ||
php-version: | ||
- "8.1" | ||
operating-system: | ||
- "ubuntu-latest" | ||
|
||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v4" | ||
|
||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: none | ||
tools: composer:v2 | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
|
||
- name: "Get Composer Cache Directory" | ||
id: composer-cache | ||
run: | | ||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: "Cache Composer dependencies" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "${{ steps.composer-cache.outputs.dir }}" | ||
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" | ||
restore-keys: | | ||
php-${{ matrix.php-version }}-locked-composer- | ||
- name: "Install locked dependencies" | ||
run: "composer install --no-interaction --no-progress" | ||
|
||
- name: "Cache PHPBench reports" | ||
uses: "actions/cache@v3" | ||
with: | ||
path: "var/phpbench" | ||
key: "php-${{ matrix.php-version }}-phpbench" | ||
restore-keys: | | ||
php-${{ matrix.php-version }}-phpbench- | ||
- name: "Benchmark" | ||
run: "composer test:benchmark -- --ref=original --progress=plain" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "./tools/phpbench/vendor/phpbench/phpbench/phpbench.schema.json", | ||
"runner.bootstrap": "vendor/autoload.php", | ||
"runner.path": [ | ||
"src/adapter/etl-adapter-avro/tests/Flow/ETL/Adapter/Avro/FlixTech/Tests/Benchmark/", | ||
"src/adapter/etl-adapter-csv/tests/Flow/ETL/Adapter/CSV/Tests/Benchmark/", | ||
"src/adapter/etl-adapter-json/tests/Flow/ETL/Tests/Benchmark/", | ||
"src/adapter/etl-adapter-parquet/tests/Flow/ETL/Adapter/Parquet/Tests/Benchmark/", | ||
"src/adapter/etl-adapter-text/tests/Flow/ETL/Adapter/Text/Tests/Benchmark/", | ||
"src/adapter/etl-adapter-xml/tests/Flow/ETL/Tests/Benchmark/", | ||
"src/core/etl/tests/Flow/ETL/Tests/Benchmark/" | ||
], | ||
"runner.progress": "dots", | ||
"storage.xml_storage_path": "var/phpbench" | ||
} |
17 changes: 17 additions & 0 deletions
17
...-adapter-avro/tests/Flow/ETL/Adapter/Avro/FlixTech/Tests/Benchmark/AvroExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Adapter\Text\Tests\Benchmark; | ||
|
||
use Flow\ETL\DSL\Avro; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class AvroExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
Avro::from(__DIR__ . '/../Fixtures/data.avro'); | ||
} | ||
} |
Binary file added
BIN
+13.1 KB
src/adapter/etl-adapter-avro/tests/Flow/ETL/Adapter/Avro/FlixTech/Tests/Fixtures/data.avro
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
src/adapter/etl-adapter-csv/tests/Flow/ETL/Adapter/CSV/Tests/Benchmark/CSVExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Adapter\Text\Tests\Benchmark; | ||
|
||
use Flow\ETL\DSL\CSV; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class CSVExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
CSV::from(__DIR__ . '/../Fixtures/annual-enterprise-survey-2019-financial-year-provisional-csv.csv'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...apter-json/tests/Flow/ETL/Tests/Benchmark/Adapter/JSON/JSONMachine/JsonExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Tests\Benchmark\Adapter\JSON\JSONMachine; | ||
|
||
use Flow\ETL\DSL\Json; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class JsonExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
Json::from(__DIR__ . '/../../../../Fixtures/timezones.json'); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...-adapter-parquet/tests/Flow/ETL/Adapter/Parquet/Tests/Benchmark/ParquetExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Adapter\Text\Tests\Benchmark; | ||
|
||
use Flow\ETL\DSL\Parquet; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class ParquetExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
Parquet::from(__DIR__ . '/../Fixtures/data.parquet'); | ||
} | ||
} |
Binary file added
BIN
+2.46 KB
src/adapter/etl-adapter-parquet/tests/Flow/ETL/Adapter/Parquet/Tests/Fixtures/data.parquet
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
...apter/etl-adapter-text/tests/Flow/ETL/Adapter/Text/Tests/Benchmark/TextExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Adapter\Text\Tests\Benchmark; | ||
|
||
use Flow\ETL\DSL\Text; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class TextExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
Text::from(__DIR__ . '/../Fixtures/annual-enterprise-survey-2019-financial-year-provisional-csv.csv'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/adapter/etl-adapter-xml/tests/Flow/ETL/Tests/Benchmark/XmlExtractorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Adapter\Text\Tests\Benchmark; | ||
|
||
use Flow\ETL\DSL\XML; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class XmlExtractorBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_extract() : void | ||
{ | ||
XML::from(__DIR__ . '/../Fixtures/simple_items.xml'); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...re/etl/tests/Flow/ETL/Tests/Benchmark/Transformer/EntryExpressionEvalTransformerBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Tests\Benchmark\Transformer; | ||
|
||
use function Flow\ETL\DSL\ref; | ||
use Flow\ETL\Config; | ||
use Flow\ETL\DSL\Entry; | ||
use Flow\ETL\FlowContext; | ||
use Flow\ETL\Row; | ||
use Flow\ETL\Rows; | ||
use Flow\ETL\Transformer\EntryExpressionEvalTransformer; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
#[Iterations(5)] | ||
final class EntryExpressionEvalTransformerBench | ||
{ | ||
#[Revs(1000)] | ||
public function bench_transform_json_row() : void | ||
{ | ||
(new EntryExpressionEvalTransformer('decoded', ref('json')->jsonDecode())) | ||
->transform( | ||
new Rows(Row::create(Entry::json('json', ['some' => 'field', 'boolean' => false]))), | ||
new FlowContext(Config::default()) | ||
); | ||
} | ||
|
||
#[Revs(1000)] | ||
public function bench_transform_string_row() : void | ||
{ | ||
(new EntryExpressionEvalTransformer('string', ref('string')->upper())) | ||
->transform( | ||
new Rows(Row::create(Entry::string('string', 'string'))), | ||
new FlowContext(Config::default()) | ||
); | ||
} | ||
|
||
#[Revs(1000)] | ||
public function bench_transform_xml_row() : void | ||
{ | ||
(new EntryExpressionEvalTransformer('xpath', ref('xml')->xpath('/root/foo'))) | ||
->transform( | ||
new Rows(Row::create(Entry::xml('xml', '<root><foo baz="buz">bar</foo><foo>baz</foo></root>'))), | ||
new FlowContext(Config::default()) | ||
); | ||
} | ||
} |
Oops, something went wrong.