duanqi6007 2016-06-23 10:08
浏览 27

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

I am taking lat, lng from mysql and load the map. But in this iteration 1000's of data loading for drawing route on map but for this process it takes too long time. After loading the code it takes 30 sec and above so please help me how to reduce the loading time of this script Thanks

<?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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line