benchmark-emit.php 674 B

12345678910111213141516171819202122232425262728
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of Evenement.
  4. *
  5. * (c) Igor Wiedler <igor@wiedler.ch>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. const ITERATIONS = 10000000;
  11. use Evenement\EventEmitter;
  12. require __DIR__.'/../vendor/autoload.php';
  13. $emitter = new EventEmitter();
  14. $emitter->on('event', function ($a, $b, $c) {});
  15. $start = microtime(true);
  16. for ($i = 0; $i < ITERATIONS; $i++) {
  17. $emitter->emit('event', [1, 2, 3]);
  18. }
  19. $time = microtime(true) - $start;
  20. echo 'Emitting ', number_format(ITERATIONS), ' events took: ', number_format($time, 2), 's', PHP_EOL;