Skip to content

Commit

Permalink
[4.x] Benchmark for async function
Browse files Browse the repository at this point in the history
This adds a somewhat boring that measures how much time it takes to spawn 1.000.000 fibers.
  • Loading branch information
WyriHaximus committed Feb 17, 2022
1 parent 83749dd commit 80f5d73
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/90-async-benchmark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use React\EventLoop\Loop;
use React\Promise\CancellablePromiseInterface;
use function React\Async\async;
use function React\Async\await;
use function React\Promise\Timer\sleep;

require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

ini_set('memory_limit', -1);

for ($i = 0; $i < 1_000_000; $i++) {
async(static fn (): bool => true)();
}

0 comments on commit 80f5d73

Please sign in to comment.