3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("STATE_ID", "3"); define("DATA_CACHE_TIMEOUT", "9999"); /** * Class to import data from SECC into SRDB * *@author Rochak Chauhan */ class ImportController extends Controller { public function actionBuffer() { header( 'Content-type: text/html; charset=utf-8' ); echo 'Begin ...<br />'; for( $i = 0 ; $i < 10 ; $i++ ) { echo $i . '<br />'; flush(); ob_flush(); sleep(1); } echo 'End ...<br />'; } public function actionIndex() { $t1 = date("r"); $ts1 = microtime(true); $tot = 0; header( 'Content-type: text/html; charset=utf-8' ); 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 " ****************************************************** "; echo "\r\n<hr /><p>Full Name: $Name_en ($Name_h) </p>\r\n"; $SRDB_District_ID = $this -> getDistrictId($District); echo "\r\n<p>District: $District ($SRDB_District_ID) </p>\r\n"; $SRDB_City_ID = $this -> getCityId($Village,$District); echo "\r\n<p>City: $Village ($SRDB_City_ID) </p>\r\n"; flush(); ob_flush(); } $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"; } /** *Function to get District ID from District Name * *@param string $District *@param int */ private function getDistrictId($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("\r\n<hr />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("\r\n<hr />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']; } } /** *Function to get City ID from City Name * *@param string $City *@param int */ private function getCityId($City, $District) { //Check record in Cache $row = Yii::app() -> cache -> get('cache_' . $City . "_" . $District); if (($row === false) || row($res)) { //Select if record exists $City = trim(strtolower($City)); $connection = Yii::app() -> db; $connection -> active = true; $command = $connection -> createCommand("SELECT LR_ID FROM tblLandRegion WHERE lower(LR_Name) = '$City' AND LR_Type='City' "); $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('$City', 'City') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x01: Failed to insert $City 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_' . $City . "_" . $District); 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) = '$City' AND LR_Type='City' ORDER BY LR_ID DESC"); $row = $command -> queryRow(); Yii::app() -> cache -> set('cache_' . $City . "_" . $District, $row, DATA_CACHE_TIMEOUT); } $City_ID = $row['LR_ID']; //Insert record in DB (Reference Table) $command = $connection -> createCommand("INSERT INTO tblCity (District_ID, City_ID) VALUES('$District_ID', '$City_ID') "); $rowCount = $command -> execute(); if ($rowCount == 0) { die("\r\n<hr />FATAL ERROR 0x02: Failed to insert $District in Reference table :: " . __FILE__ . " at line nunber " . __LINE__); } return $City_ID; } } else { //Cache and Return the PK/ID of the record. Yii::app() -> cache -> set('cache_' . $City . "_" . $District, $row, DATA_CACHE_TIMEOUT); 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)
7.4.10.0090.00915.11
7.4.00.0050.01215.03
7.3.130.0090.01014.76
7.3.120.0100.00814.95
7.3.110.0070.01014.87
7.3.100.0110.00514.99
7.3.90.0070.00414.94
7.3.80.0080.00514.95
7.3.70.0080.00514.84
7.3.60.0080.00514.91
7.3.50.0030.01114.85
7.3.40.0060.00614.88
7.3.30.0000.01114.83
7.3.20.0030.00816.64
7.3.10.0080.00516.80
7.3.00.0040.00916.67
7.2.260.0030.01714.95
7.2.250.0080.00615.01
7.2.240.0090.00715.09
7.2.230.0030.00915.02
7.2.220.0050.01215.10
7.2.210.0070.00814.97
7.2.200.0080.00714.91
7.2.190.0070.00414.78
7.2.180.0030.00714.79
7.2.170.0080.00614.95
7.2.160.0110.00315.00
7.2.150.0090.00316.86
7.2.140.0100.00316.59
7.2.130.0100.00616.96
7.2.120.0000.01216.66
7.2.110.0030.01416.68
7.2.100.0000.01216.58
7.2.90.0090.00316.58
7.2.80.0030.01116.74
7.2.70.0030.00916.62
7.2.60.0080.00616.68
7.2.50.0000.00916.60
7.2.40.0090.00616.86
7.2.30.0080.00416.88
7.2.20.0030.01216.96
7.2.10.0060.00316.99
7.2.00.0000.00916.76
7.1.330.0020.01415.64
7.1.320.0100.00815.64
7.1.310.0060.00715.45
7.1.300.0050.00715.63
7.1.290.0070.00815.62
7.1.280.0050.00915.41
7.1.270.0030.01015.39
7.1.260.0090.00615.55
7.1.250.0070.00715.61
7.1.240.0080.00415.67
7.1.230.0090.00615.52
7.1.220.0130.00315.55
7.1.210.0000.01415.45
7.1.200.0000.01715.57
7.1.190.0140.00015.29
7.1.180.0070.00415.78
7.1.170.0070.01015.76
7.1.160.0090.00615.58
7.1.150.0030.00815.73
7.1.140.0070.00715.74
7.1.130.0110.00015.28
7.1.120.0090.00615.78
7.1.110.0030.00615.52
7.1.100.0040.01115.71
7.1.90.0000.00815.68
7.1.80.0000.00915.59
7.1.70.0030.00916.30
7.1.60.0060.01117.82
7.1.50.0000.01216.11
7.1.40.0030.00915.66
7.1.30.0110.00315.45
7.1.20.0060.00315.38
7.1.10.0060.00915.81
7.1.00.0050.04419.13
7.0.330.0040.00715.15
7.0.320.0060.00315.37
7.0.310.0060.00315.16
7.0.300.0030.00615.14
7.0.290.0030.00615.25
7.0.280.0030.01015.38
7.0.270.0100.00315.22
7.0.260.0080.00615.00
7.0.250.0060.00615.05
7.0.240.0000.00815.07
7.0.230.0040.01115.06
7.0.220.0110.00415.46
7.0.210.0030.01015.10
7.0.200.0080.00316.00
7.0.190.0060.00615.15
7.0.180.0040.01215.05
7.0.170.0030.00615.06
7.0.160.0070.00315.09
7.0.150.0060.00915.24
7.0.140.0070.03518.64
7.0.130.0060.00815.29
7.0.120.0060.01015.41
7.0.110.0040.01115.38
7.0.100.0120.00315.25
7.0.90.0090.02517.66
7.0.80.0050.04717.55
7.0.70.0080.04317.63
7.0.60.0070.04217.66
7.0.50.0070.04217.91
7.0.40.0070.02716.70
7.0.30.0070.04416.61
7.0.20.0110.04416.72
7.0.10.0050.03916.74
7.0.00.0070.03916.81
5.6.400.0030.01414.36
5.6.390.0030.01014.28
5.6.380.0050.00514.05
5.6.370.0030.01214.20
5.6.360.0000.01414.04
5.6.350.0110.00314.52
5.6.340.0060.00914.09
5.6.330.0040.00814.21
5.6.320.0000.01514.09
5.6.310.0030.00614.34
5.6.300.0070.00714.29
5.6.290.0060.00314.43
5.6.280.0020.04117.77
5.6.270.0110.00714.42
5.6.260.0070.00714.36
5.6.250.0000.01114.28
5.6.240.0080.04717.49
5.6.230.0080.04517.42
5.6.220.0030.04517.36
5.6.210.0030.04717.33
5.6.200.0070.02317.69
5.6.190.0130.03617.62
5.6.180.0080.04317.86
5.6.170.0030.03317.49
5.6.160.0050.04417.63
5.6.150.0140.03717.67
5.6.140.0070.04617.69
5.6.130.0090.04617.55
5.6.120.0120.03817.76
5.6.110.0140.04017.74
5.6.100.0070.04617.71
5.6.90.0070.04717.66
5.6.80.0020.04717.35
5.6.70.0120.03917.24
5.6.60.0050.03817.42
5.6.50.0060.02517.58
5.6.40.0050.04217.37
5.6.30.0050.04717.41
5.6.20.0030.04817.32
5.6.10.0070.03917.28
5.6.00.0130.03817.43
5.5.380.0050.04517.16
5.5.370.0100.03817.27
5.5.360.0120.04017.36
5.5.350.0100.04717.28
5.5.340.0090.03917.55
5.5.330.0040.04717.59
5.5.320.0070.04017.39
5.5.310.0000.04817.59
5.5.300.0110.04217.44
5.5.290.0070.04617.68
5.5.280.0080.04317.46
5.5.270.0100.02517.52
5.5.260.0060.03317.44
5.5.250.0160.01717.49
5.5.240.0050.02717.15
5.5.230.0090.02517.23
5.5.220.0070.04617.20
5.5.210.0050.03317.14
5.5.200.0050.02717.27
5.5.190.0100.03917.23
5.5.180.0130.03617.05
5.5.170.0070.00314.17
5.5.160.0030.02817.13
5.5.150.0070.04017.11
5.5.140.0030.03416.97
5.5.130.0030.02817.16
5.5.120.0080.02317.29
5.5.110.0030.04316.96
5.5.100.0100.04017.06
5.5.90.0100.02017.10
5.5.80.0130.02817.21
5.5.70.0090.04417.11
5.5.60.0100.02317.21
5.5.50.0020.03217.02
5.5.40.0090.02116.99
5.5.30.0030.04917.02
5.5.20.0060.02817.15
5.5.10.0060.03717.12
5.5.00.0070.04416.98
5.4.450.0080.04515.21
5.4.440.0080.03315.20
5.4.430.0020.04415.23
5.4.420.0060.04315.19
5.4.410.0030.03115.13
5.4.400.0090.03615.05
5.4.390.0030.04315.12
5.4.380.0050.04115.09
5.4.370.0050.04614.96
5.4.360.0050.04115.02
5.4.350.0030.02815.11
5.4.340.0030.03615.04
5.4.330.0090.00011.03
5.4.320.0050.04015.07
5.4.310.0070.02515.02
5.4.300.0130.03315.14
5.4.290.0080.03915.10
5.4.280.0070.03814.93
5.4.270.0050.03814.93
5.4.260.0070.02315.07
5.4.250.0070.02314.98
5.4.240.0060.02315.03
5.4.230.0050.02715.07
5.4.220.0030.04214.97
5.4.210.0050.04015.10
5.4.200.0070.04215.02
5.4.190.0020.04615.05
5.4.180.0080.03715.12
5.4.170.0110.03315.09
5.4.160.0040.04114.94
5.4.150.0080.03715.01
5.4.140.0070.03513.75
5.4.130.0050.03313.70
5.4.120.0060.03713.75
5.4.110.0070.02613.67
5.4.100.0020.02513.71
5.4.90.0030.04013.78
5.4.80.0100.01713.74
5.4.70.0070.04213.76
5.4.60.0030.03913.69
5.4.50.0130.02613.77
5.4.40.0080.02213.69
5.4.30.0020.02713.77
5.4.20.0120.02813.75
5.4.10.0040.03413.75
5.4.00.0090.03813.50
5.3.290.0000.04312.83
5.3.280.0060.04212.90
5.3.270.0110.03212.80
5.3.260.0060.02812.83
5.3.250.0040.02512.85
5.3.240.0050.04512.82
5.3.230.0110.03012.83
5.3.220.0070.03912.88
5.3.210.0080.04012.80
5.3.200.0030.04512.85
5.3.190.0080.04112.84
5.3.180.0060.02412.82
5.3.170.0060.04012.82
5.3.160.0070.02712.80
5.3.150.0060.02912.86
5.3.140.0090.03212.84
5.3.130.0030.03112.79
5.3.120.0070.02312.88
5.3.110.0030.03212.79
5.3.100.0080.03212.56
5.3.90.0090.03312.59
5.3.80.0030.04212.56
5.3.70.0030.03612.61
5.3.60.0080.03612.54
5.3.50.0050.03912.47
5.3.40.0030.04312.47
5.3.30.0050.03312.51
5.3.20.0050.02212.41
5.3.10.0040.03712.36
5.3.00.0030.03812.42

preferences:
30.85 ms | 400 KiB | 5 Q