Skip to content

Commit

Permalink
Play with benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Oct 30, 2023
1 parent de3be31 commit 1ca68fd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
4 changes: 2 additions & 2 deletions phpbench.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"src/adapter/etl-adapter-xml/tests/Flow/ETL/Adapter/XML/Tests/Benchmark/",
"src/core/etl/tests/Flow/ETL/Tests/Benchmark/"
],
"runner.progress": "dots",
"runner.retry_threshold": 5,
"runner.php_config": { "memory_limit": "1G" },
"runner.iterations": 3,
"storage.xml_storage_path": "var/phpbench"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Flow\ETL\Row\Factory\NativeEntryFactory;
use PhpBench\Attributes\BeforeMethods;
use PhpBench\Attributes\Groups;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;

#[Iterations(5)]
#[BeforeMethods(['setUp'])]
#[Revs(5)]
#[Groups(['building_blocks'])]
final class NativeEntryFactoryBench
{
Expand Down Expand Up @@ -53,22 +53,16 @@ public function setUp() : void
);
}

#[BeforeMethods(['setUp'])]
#[Revs(5)]
public function bench_10k_rows() : void
{
array_to_rows($this->rowsArray, new NativeEntryFactory());
}

#[BeforeMethods(['setUp'])]
#[Revs(5)]
public function bench_1k_rows() : void
{
array_to_rows(\array_slice($this->rowsArray, 0, 1_000), new NativeEntryFactory());
}

#[BeforeMethods(['setUp'])]
#[Revs(5)]
public function bench_5k_rows() : void
{
array_to_rows(\array_slice($this->rowsArray, 0, 5_000), new NativeEntryFactory());
Expand Down
8 changes: 4 additions & 4 deletions src/core/etl/tests/Flow/ETL/Tests/Benchmark/RowsBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
use Flow\ETL\Row;
use Flow\ETL\Row\Entry\StringEntry;
use Flow\ETL\Rows;
use PhpBench\Attributes\BeforeMethods;
use PhpBench\Attributes\Groups;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;

#[Iterations(5)]
#[Revs(20)]
#[BeforeMethods('setUp')]
#[Revs(10)]
#[Groups(['building_blocks'])]
final class RowsBench
{
private Rows $reducedRows;

private Rows $rows;

public function __construct()
public function setUp() : void
{
$this->rows = Rows::fromArray(
\array_merge(...\array_map(static fn () : array => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
use Flow\ETL\FlowContext;
use Flow\ETL\Rows;
use Flow\ETL\Transformer\RenameEntryTransformer;
use PhpBench\Attributes\BeforeMethods;
use PhpBench\Attributes\Groups;
use PhpBench\Attributes\Iterations;
use PhpBench\Attributes\Revs;

#[Iterations(5)]
#[BeforeMethods('setUp')]
#[Revs(10)]
#[Groups(['transformer'])]
final class RenameEntryTransformerBench
{
private FlowContext $context;

private Rows $rows;

public function __construct()
public function setUp() : void
{
$this->rows = Rows::fromArray(
\array_merge(...\array_map(static function () : array {
Expand All @@ -34,7 +35,6 @@ public function __construct()
$this->context = new FlowContext(Config::default());
}

#[Revs(5)]
public function bench_transform_10k_rows() : void
{
(new RenameEntryTransformer('from', 'to'))->transform($this->rows, $this->context);
Expand Down

0 comments on commit 1ca68fd

Please sign in to comment.