getMemory example

return $total;
    }

    /** * Gets the max memory usage of all periods in bytes. */
    public function getMemory(): int
    {
        $memory = 0;
        foreach ($this->periods as $period) {
            if ($period->getMemory() > $memory) {
                $memory = $period->getMemory();
            }
        }

        return $memory;
    }

    /** * Return the current time relative to origin in milliseconds. */
    protected function getNow(): float
    {
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector;

class MemoryDataCollectorTest extends TestCase
{
    public function testCollect()
    {
        $collector = new MemoryDataCollector();
        $collector->collect(new Request()new Response());

        $this->assertIsInt($collector->getMemory());
        $this->assertIsInt($collector->getMemoryLimit());
        $this->assertSame('memory', $collector->getName());
    }

    /** @dataProvider getBytesConversionTestData */
    public function testBytesConversion($limit$bytes)
    {
        $collector = new MemoryDataCollector();
        $method = new \ReflectionMethod($collector, 'convertToBytes');
        $this->assertEquals($bytes$method->invoke($collector$limit));
    }

    
/** * Gets the memory usage in bytes. */
    public function getMemory(): int
    {
        return $this->memory;
    }

    public function __toString(): string
    {
        return sprintf('%.2F MiB - %d ms', $this->getMemory() / 1024 / 1024, $this->getDuration());
    }
}
Home | Imprint | This part of the site doesn't use cookies.