Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return current Unix timestamp with microseconds
<?php microtime(bool $as_float = false): string|float
<?php public function updateTime()
{
return $this->time = $this->useHighResolution ? \hrtime(true) * 1e-9 : \microtime(true);
}
public function getTime()
<?php private function assertRunSlowerThan($minInterval)
{
$start = microtime(true);
$this->loop->run();
<?php $this->loop->run();
$end = microtime(true);
$interval = $end - $start;
$this->assertLessThan($interval, $minInterval);
<?php private function assertRunFasterThan($maxInterval)
{
$start = microtime(true);
$this->loop->run();
<?php $this->loop->run();
$end = microtime(true);
$interval = $end - $start;
$this->assertLessThan($maxInterval, $interval);
<?php public function testExecuteExampleWithUncaughtExceptionShouldNotRunLoop()
{
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 11-uncaught.php 2>/dev/null');
$time = microtime(true) - $time;
<?php {
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 11-uncaught.php 2>/dev/null');
$time = microtime(true) - $time;
$this->assertLessThan(1.0, $time);
}
<?php public function testExecuteExampleWithUndefinedVariableShouldNotRunLoop()
{
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 12-undefined.php 2>/dev/null');
$time = microtime(true) - $time;
<?php {
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 12-undefined.php 2>/dev/null');
$time = microtime(true) - $time;
$this->assertLessThan(1.0, $time);
}
<?php public function testExecuteExampleWithExplicitStopShouldNotRunLoop()
{
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 21-stop.php 2>/dev/null');
$time = microtime(true) - $time;
<?php {
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 21-stop.php 2>/dev/null');
$time = microtime(true) - $time;
$this->assertLessThan(1.0, $time);
}
<?php public function testExecuteExampleWithExplicitStopInExceptionHandlerShouldNotRunLoop()
{
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 22-uncaught-stop.php 2>/dev/null');
$time = microtime(true) - $time;
<?php {
$time = microtime(true);
exec(escapeshellarg(PHP_BINARY) . ' 22-uncaught-stop.php 2>/dev/null');
$time = microtime(true) - $time;
$this->assertLessThan(1.0, $time);
}
<?php $this->expectCallableOnce()
);
$start = microtime(true);
$this->loop->run();
<?php $this->loop->run();
$end = microtime(true);
$interval = $end - $start;
$this->assertGreaterThan(0.04, $interval);