Ben nasıl olur da yeniden kod benim php komut mümkün olduğunca hızlı çalıştırmak için?

0 Cevap php

Ben varsa, durumunu kontrol edecek bir komut dosyası bir alan adı ve çıkış alanı (10 kez) çalışan ve (milisaniye ile) zaman damgası ediyorum.

Can you find anything which is slowing down the script even marignally? If you could please adjust and re-post or advise what can be done better, it would be very much appreciated! Thank you.

<?php

    date_default_timezone_set('Australia/Brisbane');
    $loops = 0; 

    function udate($format, $utimestamp = null) {
      if (is_null($utimestamp))
        $utimestamp = microtime(true);

      $timestamp = floor($utimestamp);
      $milliseconds = round(($utimestamp - $timestamp) * 1000000);

      return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
    }

    function GetCurlPage ($pageSpec)
    {
      $ch = curl_init($pageSpec);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
      $tmp = curl_exec ($ch);
      curl_close ($ch);
      $tmp = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i', '', $tmp);
      $tmp = explode('<br>', $tmp);
      foreach ($tmp AS $line) {
        //echo '<pre>';
        //print_r($line);
        //echo '</pre>';
      }
      // Do something with each line.
      echo $tmp[0];
      echo "<br>";
      echo $tmp[1];
      //echo $tmp[2];
      echo "<br>";
      echo udate('H:i:s:u');
      echo "<br><br>";

      return $tmp;

    }

    while ($loops <= 10)    
    {
$suffixes=urlencode("com.au");
$domain = "sampledomain";
$fuzzysearch = "0";
$returnUrl="http://mydomain.com.au/test.php";
$url = "https://apidomain.com.au/check.php?domain=" .
$domain . "&suffixes=" . $suffixes . "&fuzzysearch=" . $fuzzysearch;
$output = GetCurlPage("$url");

    ++$loops;
    }           
?>

0 Cevap