Skip to content

Commit

Permalink
Project was renamed to Benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Feb 6, 2023
1 parent b22e96e commit 2717f2e
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ body:
attributes:
label: Environment
description: |
Tip: Use the `composer info dragon-code/runtime-comparison` command to get information for Laravel Lang.
Tip: Use the `composer info dragon-code/benchmark` command to get information for Laravel Lang.
Tip: Use the `php -v` command to get information for PHP.
value: |
- PHP Version:
- Runtime Comparison Version:
- Benchmark Version:
validations:
required: true

Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Runtime Comparison
# Benchmark

![the dragon code runtime comparison](https://preview.dragon-code.pro/the-dragon-code/runtime-comparison.svg?brand=php)
![the dragon code benchmark](https://preview.dragon-code.pro/the-dragon-code/benchmark.svg?brand=php)

[![Stable Version][badge_stable]][link_packagist]
[![Unstable Version][badge_unstable]][link_packagist]
Expand All @@ -10,18 +10,18 @@

## Installation

To get the latest version of `Runtime Comparison`, simply require the project using [Composer](https://getcomposer.org):
To get the latest version of `The Dragon Code: Benchmark`, simply require the project using [Composer](https://getcomposer.org):

```bash
composer require dragon-code/runtime-comparison --dev
composer require dragon-code/benchmark --dev
```

Or manually update `require-dev` block of `composer.json` and run `composer update` console command:

```json
{
"require-dev": {
"dragon-code/runtime-comparison": "^1.0"
"dragon-code/benchmark": "^1.0"
}
}
```
Expand All @@ -33,19 +33,19 @@ Or manually update `require-dev` block of `composer.json` and run `composer upda
> The result of the execution is printed to the console, so make sure you call the code from the console.
```php
use DragonCode\RuntimeComparison\Comparator;
use DragonCode\Benchmark\Benchmark;

(new Comparator())->compare(
(new Benchmark())->compare(
fn () => /* some code */,
fn () => /* some code */,
);

(new Comparator())->compare([
(new Benchmark())->compare([
fn () => /* some code */,
fn () => /* some code */,
]);

(new Comparator())->compare([
(new Benchmark())->compare([
'foo' => fn () => /* some code */,
'bar' => fn () => /* some code */,
]);
Expand Down Expand Up @@ -82,12 +82,12 @@ When measuring the average value among the results, when more than 10 iterations

### Iterations Count

By default, the comparator performs 100 iterations per callback, but you can change this number by calling the `iterations` method:
By default, the benchmark performs 100 iterations per callback, but you can change this number by calling the `iterations` method:

```php
use DragonCode\RuntimeComparison\Comparator;
use DragonCode\Benchmark\Benchmark;

(new Comparator())
(new Benchmark())
->iterations(5)
->compare(
fn () => /* some code */,
Expand All @@ -103,9 +103,9 @@ If you want to see only the summary result of the run time without detailed info
summary information:

```php
use DragonCode\RuntimeComparison\Comparator;
use DragonCode\Benchmark\Benchmark;

(new Comparator())
(new Benchmark())
->withoutData()
->compare([
'foo' => fn () => /* some code */,
Expand Down Expand Up @@ -139,9 +139,9 @@ By default, the script does not round measurement results, but you can specify t
For example:

```php
use DragonCode\RuntimeComparison\Comparator;
use DragonCode\Benchmark\Benchmark;

(new Comparator())
(new Benchmark())
->iterations(5)
->round(2)
->compare(
Expand Down Expand Up @@ -175,18 +175,18 @@ Result example:
This package is licensed under the [MIT License](LICENSE).


[badge_build]: https://img.shields.io/github/actions/workflow/status/TheDragonCode/runtime-comparison/phpunit.yml?style=flat-square
[badge_build]: https://img.shields.io/github/actions/workflow/status/TheDragonCode/benchmark/phpunit.yml?style=flat-square

[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/runtime-comparison.svg?style=flat-square
[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/benchmark.svg?style=flat-square

[badge_license]: https://img.shields.io/packagist/l/dragon-code/runtime-comparison.svg?style=flat-square
[badge_license]: https://img.shields.io/packagist/l/dragon-code/benchmark.svg?style=flat-square

[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/runtime-comparison?label=stable&style=flat-square
[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/benchmark?label=stable&style=flat-square

[badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square

[link_build]: https://github.com/TheDragonCode/runtime-comparison/actions
[link_build]: https://github.com/TheDragonCode/benchmark/actions

[link_license]: LICENSE

[link_packagist]: https://packagist.org/packages/dragon-code/runtime-comparison
[link_packagist]: https://packagist.org/packages/dragon-code/benchmark
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "dragon-code/runtime-comparison",
"description": "Simple comparison of execution time of different code",
"name": "dragon-code/benchmark",
"description": "Simple comparison of code execution speed between different options",
"license": "MIT",
"type": "library",
"keywords": [
"benchmark",
"runtime",
"comparison",
"comparison-tool",
Expand All @@ -22,8 +23,8 @@
}
],
"support": {
"issues": "https://github.com/TheDragonCode/runtime-comparison/issues",
"source": "https://github.com/TheDragonCode/runtime-comparison"
"issues": "https://github.com/TheDragonCode/benchmark/issues",
"source": "https://github.com/TheDragonCode/benchmark"
},
"funding": [
{
Expand Down Expand Up @@ -55,7 +56,7 @@
"prefer-stable": true,
"autoload": {
"psr-4": {
"DragonCode\\RuntimeComparison\\": "src/"
"DragonCode\\Benchmark\\": "src/"
}
},
"autoload-dev": {
Expand Down
14 changes: 7 additions & 7 deletions src/Comparator.php → src/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison;
namespace DragonCode\Benchmark;

use DragonCode\RuntimeComparison\Exceptions\ValueIsNotCallableException;
use DragonCode\RuntimeComparison\Services\Runner;
use DragonCode\RuntimeComparison\Services\View;
use DragonCode\RuntimeComparison\Transformers\Transformer;
use DragonCode\Benchmark\Exceptions\ValueIsNotCallableException;
use DragonCode\Benchmark\Services\Runner;
use DragonCode\Benchmark\Services\View;
use DragonCode\Benchmark\Transformers\Transformer;
use Symfony\Component\Console\Helper\ProgressBar as ProgressBarService;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;

class Comparator
class Benchmark
{
protected View $view;

Expand All @@ -24,7 +24,7 @@ class Comparator
protected array $result = [];

public function __construct(
protected Runner $runner = new Runner(),
protected Runner $runner = new Runner(),
protected Transformer $transformer = new Transformer()
) {
$this->view = new View(new SymfonyStyle(
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Contracts;
namespace DragonCode\Benchmark\Contracts;

interface Transformer
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ValueIsNotCallableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Exceptions;
namespace DragonCode\Benchmark\Exceptions;

use TypeError;

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Services;
namespace DragonCode\Benchmark\Services;

class Arr
{
Expand Down
2 changes: 1 addition & 1 deletion src/Services/MeasurementError.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Services;
namespace DragonCode\Benchmark\Services;

class MeasurementError
{
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Services;
namespace DragonCode\Benchmark\Services;

class Runner
{
Expand Down
6 changes: 3 additions & 3 deletions src/Services/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Services;
namespace DragonCode\Benchmark\Services;

use DragonCode\RuntimeComparison\View\ProgressBar;
use DragonCode\RuntimeComparison\View\Table;
use DragonCode\Benchmark\View\ProgressBar;
use DragonCode\Benchmark\View\Table;
use Symfony\Component\Console\Style\SymfonyStyle;

class View
Expand Down
4 changes: 2 additions & 2 deletions src/Transformers/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

use DragonCode\RuntimeComparison\Contracts\Transformer as TransformerContract;
use DragonCode\Benchmark\Contracts\Transformer as TransformerContract;

abstract class Base implements TransformerContract
{
Expand Down
2 changes: 1 addition & 1 deletion src/Transformers/Separator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

use Symfony\Component\Console\Helper\TableSeparator;

Expand Down
4 changes: 2 additions & 2 deletions src/Transformers/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

use DragonCode\RuntimeComparison\Services\MeasurementError;
use DragonCode\Benchmark\Services\MeasurementError;

class Stats extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/Transformers/Times.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

class Times extends Base
{
Expand Down
4 changes: 2 additions & 2 deletions src/Transformers/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

use DragonCode\RuntimeComparison\Contracts\Transformer as TransformerContract;
use DragonCode\Benchmark\Contracts\Transformer as TransformerContract;

class Transformer
{
Expand Down
4 changes: 2 additions & 2 deletions src/Transformers/Winner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\Transformers;
namespace DragonCode\Benchmark\Transformers;

use DragonCode\RuntimeComparison\Services\Arr;
use DragonCode\Benchmark\Services\Arr;

class Winner extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion src/View/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\View;
namespace DragonCode\Benchmark\View;

use Symfony\Component\Console\Helper\ProgressBar as ProgressBarService;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand Down
2 changes: 1 addition & 1 deletion src/View/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DragonCode\RuntimeComparison\View;
namespace DragonCode\Benchmark\View;

use Symfony\Component\Console\Style\SymfonyStyle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Tests\Comparator;
namespace Tests\Benchmark;

use Tests\TestCase;

class AsArrayTest extends TestCase
{
public function testDefault(): void
{
$this->comparator()->compare([
$this->benchmark()->compare([
'foo' => fn () => $this->work(),
'bar' => fn () => $this->work(),
]);
Expand All @@ -20,12 +20,12 @@ public function testDefault(): void

public function testIterations(): void
{
$this->comparator()->iterations(5)->compare([
$this->benchmark()->iterations(5)->compare([
'foo' => fn () => $this->work(),
'bar' => fn () => $this->work(),
]);

$this->comparator()->iterations(500)->withoutData()->compare([
$this->benchmark()->iterations(500)->withoutData()->compare([
'foo' => fn () => $this->work(),
'bar' => fn () => $this->work(),
]);
Expand All @@ -35,7 +35,7 @@ public function testIterations(): void

public function testWithoutData(): void
{
$this->comparator()->withoutData()->compare([
$this->benchmark()->withoutData()->compare([
'foo' => fn () => $this->work(),
'bar' => fn () => $this->work(),
]);
Expand All @@ -45,7 +45,7 @@ public function testWithoutData(): void

public function testRound(): void
{
$this->comparator()->round(2)->compare([
$this->benchmark()->round(2)->compare([
'foo' => fn () => $this->work(),
'bar' => fn () => $this->work(),
]);
Expand Down
Loading

0 comments on commit 2717f2e

Please sign in to comment.