Swoole\Coroutine::getElapsed(int $cid = 0)

Notice: ext-swoole is supported until v4.7.1, use ext-openswoole >= v4.7.1. Latest version: pecl install openswoole-4.9.1

Declaration

<?php
Swoole\Coroutine::getElapsed(int $cid = 0)

Parameters

cid

Coroutine ID. By default, use the ID of current coroutine.

Return

elapsed

The elasped time of a coroutine

Description

Get the elapsed execution duration of a coroutine by coroutine ID.

Example

<?php
Co\run(function () {
    co::sleep(1.2);
    echo Swoole\Coroutine::getElapsed();
});