benchmark.php$0 ➔ exception()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BM_TEST;
4
5
require 'vendor/autoload.php';
6
7
use Carno\Chain\Layered;
8
use Carno\Chain\Layers;
9
use Carno\Coroutine\Context;
10
use Throwable;
11
12
$layers = new Layers(
13
    $c = new class implements Layered {
14
        public function inbound($message, Context $ctx)
15
        {
16
            return $message;
17
        }
18
        public function outbound($message, Context $ctx)
19
        {
20
            return $message;
21
        }
22
        public function exception(Throwable $e, Context $ctx)
23
        {
24
            throw $e;
25
        }
26
    },
27
    clone $c
28
);
29
30
$begin = microtime(true);
31
32
for ($r = 0; $r < 102400; $r ++) {
33
    $layers->handler()($r);
34
}
35
36
$cost = round((microtime(true) - $begin) * 1000);
37
38
echo 'cost ', $cost, ' ms | op ', round($cost * 1000 / $r, 3), ' μs', PHP_EOL;
39