1

I am trying to test average pageLoad time, sending requests with PhantomJS php engine, using Symfony. Why for some pages half of the time I recieve 408 response, and only half - 200? Is there some delay or option additionaly needed?

public function loadPage($thePage){

    $testResults = [];
    $errorCount = 0;
    $statusCodes = [];

    $client = Client::getInstance();
    $upOne = realpath(__DIR__ . '/../../..');
    $client->getEngine()->setPath($upOne.'/bin/phantomjs');

    $client->getEngine()->addOption('--load-images=true');
    $client->getEngine()->addOption('--ignore-ssl-errors=true');

    $client->isLazy();

        $request = $client->getMessageFactory()->createRequest($thePage, 'GET');
        $request->setTimeout(10000);

        $response = $client->getMessageFactory()->createResponse();

        for($i = 0; $i < 10; $i++) {

            $startScriptTime = microtime(TRUE);

            $client->send($request, $response);

                if($response->getStatus() !== 200) {

                    $errorCount++;
                }

            $endScriptTime = microtime(TRUE);
            $totalScriptTime = $endScriptTime - $startScriptTime;
            $loadTime = number_format($totalScriptTime, 4);

            $statusCodes[] = [$response->getStatus(), $loadTime];

            if($response->getStatus() == 200){
                $testResults[] = $loadTime;
            }
        }

    $outcome = [$this->getAverageNoExtremes($testResults), $errorCount, $statusCodes];
    return $outcome;
}

0 Answers0