如何减少php脚本的加载时间

时间:2016-06-23 10:08:49

标签: php

我从mysql中取lat,lng并加载地图。但是在这次迭代中,1000个数据加载用于在地图上绘制路线,但是对于这个过程,需要花费太长时间。 加载代码后需要30秒以上,所以请帮我如何减少这个脚本的加载时间 感谢

<?php
    $result=mysql_query("select * from marker1 where  date='$maxdate' and time BETWEEN '$mintime' AND '$maxtime' and imei_no='$vehicle_imei_no1'")or die(mysql_error());

    $markers =new SimpleXMLElement('<markers/>');//Create SimpleXMLElement object
    while($row = mysql_fetch_assoc($result)){ //Add each column value a node of the XML object
    $marker = $markers->addChild('marker');
    $marker->addChild('lat',$row['lat']);
    $marker->addChild('lng',$row['lng']);
    $marker->addChild('date',$row['date']);
    $marker->addChild('time',$row['time']);
    $marker->addChild('speed',$row['speed']);
    $marker->addChild('vehicle_status',$row['vehicle_status']);

    array_push($lat_lng,$row['lat'],$row['lng']);

    if($row['vehicle_status']=='M' && $row['speed'] >3){
    array_push($allTime,$row['time']);
    }else {
    array_push($allTime,-1);
    }

    if($row['vehicle_status']=='M' && $row['speed'] <= 3 ){
    array_push($parkedTime,$row['time']);
    }else {
    array_push($parkedTime,-1);
    }

    }

      $fp=fopen('genxml.xml','wb'); //Create the XML file
      fwrite($fp,$markers->asXML());      //Write the XML nodes
      fclose($fp);  
    include 'currentlocation1.php';

    ?>

0 个答案:

没有答案