Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8
Forces collection of any existing garbage cycles
<?php gc_collect_cycles(): int
<?php {
return collect(Arr::wrap($benchmarkables))->map(function ($callback) use ($iterations) {
return collect(range(1, $iterations))->map(function () use ($callback) {
gc_collect_cycles();
$start = hrtime(true);
<?php public static function value(callable $callback): array
{
gc_collect_cycles();
$start = hrtime(true);
<?php $first = $instance->rand();
unset($instance);
gc_collect_cycles();
$instance = new MyClass();
$second = $instance->rand();
<?php $garbage = (int) $event->app->make('config')->get('octane.garbage');
if ($garbage && (memory_get_usage() / 1024 / 1024) > $garbage) {
gc_collect_cycles();
}
}
}
<?php gc_collect_cycles();
gc_disable();
if ($this->updateAllowList && $this->updateMirrors) {
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$dns = new Deferred();
<?php }
gc_collect_cycles();
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
$dns = new Deferred();
$this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('example.com'))->willReturn($dns->promise());
<?php $dns->reject(new \RuntimeException('DNS failed'));
unset($promise, $dns);
$this->assertEquals(0, gc_collect_cycles());
}
public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferences()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$dns = new Deferred();
$this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('example.com'))->willReturn($dns->promise());
<?php $tcp->reject(new \RuntimeException('Connection failed'));
unset($promise, $dns, $tcp);
$this->assertEquals(0, gc_collect_cycles());
}
public function testRejectionAfterDnsLookupShouldNotCreateAnyGarbageReferencesAgain()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$dns = new Deferred();
$this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('example.com'))->willReturn($dns->promise());
<?php unset($promise, $dns, $tcp);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCancelDuringDnsLookupShouldNotCreateAnyGarbageReferences()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$dns = new Deferred(function () {
throw new \RuntimeException();
<?php $promise->cancel();
unset($promise, $dns);
$this->assertEquals(0, gc_collect_cycles());
}
public function testCancelDuringTcpConnectionShouldNotCreateAnyGarbageReferences()
<?php $this->markTestSkipped('Not supported on legacy Promise v1 API');
}
gc_collect_cycles();
$dns = new Deferred();
$this->resolver->expects($this->once())->method('resolve')->with($this->equalTo('example.com'))->willReturn($dns->promise());