Skip to content

Commit 80f5d73

Browse files
committed
[4.x] Benchmark for async function
This adds a somewhat boring that measures how much time it takes to spawn 1.000.000 fibers.
1 parent 83749dd commit 80f5d73

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/90-async-benchmark.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use React\EventLoop\Loop;
4+
use React\Promise\CancellablePromiseInterface;
5+
use function React\Async\async;
6+
use function React\Async\await;
7+
use function React\Promise\Timer\sleep;
8+
9+
require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
10+
11+
ini_set('memory_limit', -1);
12+
13+
for ($i = 0; $i < 1_000_000; $i++) {
14+
async(static fn (): bool => true)();
15+
}

0 commit comments

Comments
 (0)