Skip to content

Commit

Permalink
Simplify Rows::drop() method (#666)
Browse files Browse the repository at this point in the history
* Simplify `Rows::drop()` method

* Rework benchmark scripts in `composer.json`

* Fixed benchmark names

---------

Co-authored-by: Norbert Orzechowicz <1921950+norberttech@users.noreply.github.com>
  • Loading branch information
stloyd and norberttech committed Oct 29, 2023
1 parent 45c2b1d commit a929620
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,31 @@ jobs:
echo '<details><summary>Extractors</summary>'
echo ' '
echo '```shell'
composer test:benchmark -- --ref=1.x --progress=none --group=extractor
composer test:benchmark:extractor -- --ref=1.x --progress=none
echo '```'
echo ' '
echo '</details>'
echo ' '
echo '<details><summary>Transformers</summary>'
echo ' '
echo '```shell'
composer test:benchmark -- --ref=1.x --progress=none --group=transformer
composer test:benchmark:transformer -- --ref=1.x --progress=none
echo '```'
echo ' '
echo '</details>'
echo ' '
echo '<details><summary>Loaders</summary>'
echo ' '
echo '```shell'
composer test:benchmark -- --ref=1.x --progress=none --group=loader
composer test:benchmark:loader -- --ref=1.x --progress=none
echo '```'
echo ' '
echo '</details>'
echo ' '
echo '<details><summary>Building Blocks</summary>'
echo ' '
echo '```shell'
composer test:benchmark -- --ref=1.x --progress=none --group=building_blocks
composer test:benchmark:building_blocks -- --ref=1.x --progress=none
echo '```'
echo ' '
echo '</details>'
Expand Down
17 changes: 16 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,22 @@
"tools/phpunit/vendor/bin/phpunit"
],
"test:benchmark": [
"tools/phpbench/vendor/bin/phpbench run --report=flow-report"
"@test:benchmark:building_blocks",
"@test:benchmark:extractor",
"@test:benchmark:loader,",
"@test:benchmark:transformer"
],
"test:benchmark:building_blocks": [
"tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=building_blocks"
],
"test:benchmark:extractor": [
"tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=extractor"
],
"test:benchmark:loader": [
"tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=loader"
],
"test:benchmark:transformer": [
"tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=transformer"
],
"test:mutation": [
"tools/infection/vendor/bin/infection -j2"
Expand Down
8 changes: 1 addition & 7 deletions src/core/etl/src/Flow/ETL/Rows.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,7 @@ public function diffRight(self $rows) : self

public function drop(int $size) : self
{
$rows = $this->rows;

for ($i = 0; $i < $size; $i++) {
\array_shift($rows);
}

return new self(...$rows);
return new self(...\array_slice($this->rows, $size));
}

public function dropRight(int $size) : self
Expand Down
10 changes: 9 additions & 1 deletion src/core/etl/tests/Flow/ETL/Tests/Benchmark/RowsBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ public function __construct()
}

#[Revs(5)]
public function bench_chunk_10() : void
public function bench_chunk_10_on_10k() : void
{
foreach ($this->rows->chunks(10) as $chunk) {

}
}

#[Revs(5)]
public function bench_drop_100_on_10k() : void
{
foreach ($this->rows->drop(100) as $chunk) {

}
}
}

0 comments on commit a929620

Please sign in to comment.