-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize performance, smart lazy sort
- Loading branch information
Showing
12 changed files
with
209 additions
and
23 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,50 @@ | ||
<?php | ||
|
||
use Blackfire\Client; | ||
use Blackfire\Profile\Configuration; | ||
use PTS\Events\Events; | ||
use PTS\Events\Filters; | ||
use PTS\Events\ResolveHandler; | ||
|
||
require_once __DIR__ .'/../vendor/autoload.php'; | ||
|
||
$iterations = $argv[1] ?? 1000; | ||
$blackfire = $argv[2] ?? false; | ||
$iterations++; | ||
|
||
if ($blackfire) { | ||
$client = new Client; | ||
$probe = $client->createProbe(new Configuration); | ||
} | ||
|
||
$startTime = microtime(true); | ||
$resolver = new ResolveHandler; | ||
$events = new Events($resolver); | ||
$filters = new Filters($resolver); | ||
|
||
|
||
$events->on('event-a', function (int $a) { | ||
return $a; | ||
}, 50, [1, 2])->on('event-a', function (int $b) { | ||
return $b; | ||
}); | ||
|
||
$filters->on('filter-a', function(int $a, int $b) { | ||
return $a; | ||
}, 50, [1, 2])->on('filter-a', function (int $a, int $b) { | ||
return $a; | ||
}); | ||
|
||
|
||
while ($iterations--) { | ||
$events->emit('event-a', [1]); | ||
$filters->filter('filter-a', 1, [3]); | ||
} | ||
|
||
$diff = (microtime(true) - $startTime) * 1000; | ||
echo sprintf('%2.3f ms', $diff); | ||
echo "\n" . memory_get_peak_usage()/1024; | ||
|
||
if ($blackfire) { | ||
$client->endProbe($probe); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PTS\Events; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PTS\Events; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace PTS\Events; | ||
|
||
|
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