How can I adjust the server to run my PHP script quicker? -
i have php script runs on loop x amount of times. code minimal , performs checks. loops run within 1 second of each other , varies.. loops run 8 seconds delay.
how or can adjust/tweak on server (or instruct manager of dedicated server) reduce time between loops milliseconds (or quick possible) rather 1 8 seconds?
thank you!
php code
<style type="text/css"> #check { font: arial, helvetica, sans-serif; font-size: 12px; margin-bottom: 40px; } .red { color: #c00; } .green { color: #060; } </style> <?php date_default_timezone_set('australia/brisbane'); $var1 = "variable"; $var2 = 1; $var3=="no"; while ($var2 <= 50) { $sapiurl = "https://www.apiurl.com/"; $aparams = array( 'uid' => "user", 'pw' => "key", 'command' => "command", 'sld' => "main", 'tld' => "ext"); $ocurl = curl_init(); curl_setopt($ocurl, curlopt_url, $sapiurl); curl_setopt($ocurl, curlopt_post, 1); curl_setopt($ocurl, curlopt_postfields, $aparams); curl_setopt($ocurl, curlopt_returntransfer, true); curl_setopt($ocurl, curlopt_ssl_verifypeer, false); $sresponse = curl_exec($ocurl); curl_close($ocurl); $ooutput = new simplexmlelement($sresponse); foreach ($ooutput $v1) { foreach ($v1 $v2) { foreach ($v2 $v3) { foreach ($v3 $v4=>$temp) { if($v4=="text") $var4 = $temp; if($var4=="true") { $aparams = array( 'uid' => "user", 'pw' => "key", 'command' => "command", 'sld' => "main", 'tld' => "ext", 'dosomething' => "yes"); $ocurl = curl_init(); curl_setopt($ocurl, curlopt_url, $sapiurl); curl_setopt($ocurl, curlopt_post, 1); curl_setopt($ocurl, curlopt_postfields, $aparams); curl_setopt($ocurl, curlopt_returntransfer, true); curl_setopt($ocurl, curlopt_ssl_verifypeer, false); $sresponse = curl_exec($ocurl); curl_close($ocurl); $var3=="yes"; } } } } } $checktime = date('h:i:s a'); echo "<div id=\"check\">$checktime, checked $var1<br>"; if ($var4=="true") echo "<div class=\"green\"> $var4"; else echo "<div class=\"red\"> $var4"; if ($var3=="yes") echo " , yes"; echo "</div></div>"; $var3=="no"; $loops++; } ?>
processor information
processor #1 vendor: genuineintel processor #1 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #1 speed: 1995.120 mhz processor #1 cache size: 6144 kb
processor #2 vendor: genuineintel processor #2 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #2 speed: 1995.120 mhz processor #2 cache size: 6144 kb
processor #3 vendor: genuineintel processor #3 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #3 speed: 1995.120 mhz processor #3 cache size: 6144 kb
processor #4 vendor: genuineintel processor #4 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #4 speed: 1995.120 mhz processor #4 cache size: 6144 kb
processor #5 vendor: genuineintel processor #5 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #5 speed: 1995.120 mhz processor #5 cache size: 6144 kb
processor #6 vendor: genuineintel processor #6 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #6 speed: 1995.120 mhz processor #6 cache size: 6144 kb
processor #7 vendor: genuineintel processor #7 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #7 speed: 1995.120 mhz processor #7 cache size: 6144 kb
processor #8 vendor: genuineintel processor #8 name: intel(r) xeon(r) cpu e5405 @ 2.00ghz processor #8 speed: 1995.120 mhz processor #8 cache size: 6144 kb
memory information
memory crash kernel (0x0 0x0) notwithin permissible range memory: 8302344k/9175040k available (2176k kernel code, 80272k reserved, 901k data, 228k init, 7466304k highmem)
system information
linux server.myserver.com 2.6.18-194.17.1.el5pae #1 smp wed sep 29 13:31:51 edt 2010 i686 i686 i386 gnu/linux
physical disks
scsi device sda: 1952448512 512-byte hdwr sectors (999654 mb) sda: write protect off sda: mode sense: 03 00 00 08 scsi device sda: drive cache: write scsi device sda: 1952448512 512-byte hdwr sectors (999654 mb) sda: write protect off sda: mode sense: 03 00 00 08 scsi device sda: drive cache: write sd 0:1:0:0: attached scsi disk sda sd 4:0:0:0: attached scsi removable disk sdb sd 0:1:0:0: attached scsi generic sg4 type 0 sd 4:0:0:0: attached scsi generic sg7 type 0
current memory usage
total used free shared buffers cached
mem: 8306672 7887632 419040 0 508076 6496876 -/+ buffers/cache: 882680 7423992 swap: 4095992 428 4095564 total: 12402664 7888060 4514604
current disk usage
filesystem size used avail use% mounted on /dev/mapper/volgroup00-logvol00 898g 200g 653g 24% / /dev/sda1 99m 19m 76m 20% /boot none 4.0g 0 4.0g 0% /dev/shm /var/tmpmnt 4.0g 161m 3.6g 5% /tmp
do use databases, emails, web services, or other similar component? generally, performance of php script dependent on these.
you can use profiling tool xdebug analyse script , find slowest areas of code. can optimise code (e.g. inner loops) improve performance.
Comments
Post a Comment