-
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
- Loading branch information
Showing
6 changed files
with
1,602 additions
and
0 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
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,6 @@ | ||
{ | ||
"$schema": "./tools/phpbench/vendor/phpbench/phpbench/phpbench.schema.json", | ||
"runner.bootstrap": "vendor/autoload.php", | ||
"runner.path": "src/core/etl/tests/Flow/ETL/Tests/Benchmark/", | ||
"runner.progress": "dots" | ||
} |
43 changes: 43 additions & 0 deletions
43
src/core/etl/tests/Flow/ETL/Tests/Benchmark/Row/Reference/Expression/AddJsonBench.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,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Tests\Benchmark\Row\Reference\Expression; | ||
|
||
use function Flow\ETL\DSL\lit; | ||
use function Flow\ETL\DSL\ref; | ||
use Flow\ETL\DSL\From; | ||
use Flow\ETL\DSL\To; | ||
use Flow\ETL\Flow; | ||
use Flow\ETL\Memory\ArrayMemory; | ||
use PhpBench\Attributes\Iterations; | ||
use PhpBench\Attributes\Revs; | ||
|
||
final class AddJsonBench | ||
{ | ||
#[Revs(100)] | ||
#[Iterations(5)] | ||
public function benchAddingJson() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array([['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3]]]) | ||
) | ||
->withEntry('array', ref('array')->arrayMerge(lit(['d' => 4]))) | ||
->write(To::memory(new ArrayMemory())) | ||
->run(); | ||
} | ||
|
||
#[Revs(100)] | ||
#[Iterations(5)] | ||
public function benchAddingJsonStringIntoExistingReference() : void | ||
{ | ||
(new Flow()) | ||
->read( | ||
From::array([['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3]]]) | ||
) | ||
->withEntry('json', lit('{"d": 4}')) | ||
->withEntry('array', ref('array')->arrayMerge(ref('json')->jsonDecode())) | ||
->drop('json') | ||
->write(To::memory(new ArrayMemory())) | ||
->run(); | ||
} | ||
} |
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 @@ | ||
vendor |
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,10 @@ | ||
{ | ||
"name": "flow-php/etl-tools", | ||
"description": "Flow PHP ETL - Tools", | ||
"require-dev": { | ||
"phpbench/phpbench": "^1.2" | ||
}, | ||
"config": { | ||
"allow-plugins": false | ||
} | ||
} |
Oops, something went wrong.