3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("STATE_ID","3"); define("DATA_CACHE_TIMEOUT","9999"); class ImportController extends Controller { public function actionIndex() { $t1=date("r"); $ts1=microtime(true); $tot=0; echo "\r\n<p> ******** Started at $t1 ******** </p>\r\n"; $connection = Yii::app()->db; $command = $connection->createCommand('SELECT * FROM seccsirsa LIMIT 0,10'); $rows = $command->queryAll(); //executes the SQL statement and returns the first row of the //$res = array(); foreach ($rows as $row) { extract($row); echo "\r\n<p>Full Name: $Name_en ($Name_h) </p>\r\n"; //echo "<br /> ".$this->getDistId($District."DEL"); echo "<br /> ".$this->getDistId($District); } $t2=date("r"); $ts2=microtime(true); $diff=($ts2-$ts1); echo "\r\n<p> ******** Stopped at $t2 ******** </p>\r\n"; echo "\r\n<p> ******** Total Execution Time: $diff microseconds ******** </p>\r\n"; echo "\r\n<p> ******** Total Records Imported: $tot ******** </p>\r\n"; } private function getDistId($District){ //Select if record exists $District=trim(strtolower($District)); $connection = Yii::app()->db; $connection->active=true; $command = $connection->createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' "); $row = $command->queryRow(); //If no record found if($row===false){ //Insert record in DB (Master Table) $command = $connection->createCommand("INSERT INTO tblLandRegion (LR_Name,LR_Type) VALUES('$District', 'District') "); $rowCount=$command->execute(); if($rowCount==0){ die("FATAL ERROR 0x01: Failed to insert $District in Master table :: ".__FILE__." at line nunber ."__LINE__); } else{ //Cache and Return the PK/ID of the new inserted record. $row = Yii::app()->cache->get('cache_'.$District."_".STATE_ID); if (($row === false) || row($res)) { $District=trim(strtolower($District)); $connection = Yii::app()->db; $command = $connection->createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$District' AND LR_Type='District' ORDER BY LR_ID DESC"); $row = $command->queryRow(); Yii::app()->cache->set('cache_'.$District."_".STATE_ID, $row, DATA_CACHE_TIMEOUT); } $District_ID=$row['LR_ID']; //Insert record in DB (Reference Table) $command = $connection->createCommand("INSERT INTO tblDistrict (District_ID, State_ID) VALUES('$District_ID', '".STATE_ID."') "); $rowCount=$command->execute(); if($rowCount==0){ die("FATAL ERROR 0x02: Failed to insert $District in Reference table :: ".__FILE__." at line nunber ."__LINE__); } return $District_ID; } } else{ //Return the PK/ID of the record. return $row['LR_ID']; } } } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.270.0100.04212.39
5.4.260.0090.04312.39
5.4.250.0090.04312.39
5.4.240.0100.04012.39
5.4.230.0070.05212.38
5.4.220.0110.04612.38
5.4.210.0080.04312.38
5.4.200.0090.04912.38
5.4.190.0050.04312.38
5.4.180.0140.04112.38
5.4.170.0170.04912.39
5.4.160.0040.03912.38
5.4.150.0090.04012.38
5.4.140.0090.04112.07
5.4.130.0090.03612.05
5.4.120.0090.04212.02
5.4.110.0090.04712.01
5.4.100.0100.03812.01
5.4.90.0120.05112.01
5.4.80.0080.04712.01
5.4.70.0100.04512.01
5.4.60.0090.03612.01
5.4.50.0070.03812.01
5.4.40.0070.03812.00
5.4.30.0110.05611.99
5.4.20.0110.04011.99
5.4.10.0090.04911.99
5.4.00.0080.05011.49
5.3.280.0110.04212.71
5.3.270.0070.05112.72
5.3.260.0070.04112.72
5.3.250.0140.04912.72
5.3.240.0120.04612.72
5.3.230.0110.04312.71
5.3.220.0110.04512.68
5.3.210.0070.05012.68
5.3.200.0090.04112.68
5.3.190.0090.04612.68
5.3.180.0120.05112.67
5.3.170.0110.04112.67
5.3.160.0120.04712.67
5.3.150.0100.04512.67
5.3.140.0090.03812.66
5.3.130.0100.04312.66
5.3.120.0090.04512.66
5.3.110.0090.04012.66
5.3.100.0110.04312.12
5.3.90.0080.04012.09
5.3.80.0070.03812.08
5.3.70.0090.03912.08
5.3.60.0080.03812.06
5.3.50.0070.03912.00
5.3.40.0060.03912.00
5.3.30.0060.04311.97
5.3.20.0070.03811.75
5.3.10.0090.03511.71
5.3.00.0060.03711.70

preferences:
135.78 ms | 1394 KiB | 7 Q