3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Outside of the application, e.g. DB, RPC or some storage. function addSomeIntegerFieldToDB($value) { $sql = 'INSERT INTO mytable (integer_field) VALUES (:int)'; // $st = $pdo->prepare($sql); // $st->execute(array('int' => $value); echo "executing query: ".str_replace(':int', $value, $sql)." \n"; } // the application: global $conditional; global $withAssert; class X { public function doSmth($id) { global $conditional; global $withAssert; if ($withAssert) { // Assertion will run outside of the if/else below // Preventing a wrong $id to be passed to ->doSmth() method, independent of the $conditional assert(is_int($id), new \InvalidArgumentException('wot ar y doin')); } if ($conditional) { addSomeIntegerFieldToDB($id); } } } $obj = new X; $withAssert = false; $conditional = true; // Assert off, conditional on $obj->doSmth(13); $obj->doSmth('x'); // Assert off, conditional off $conditional = false; $obj->doSmth(13); $obj->doSmth('x'); // Assert on, conditional on $withAssert = true; $conditional = true; $obj->doSmth(13); $obj->doSmth('x'); // Assert on, conditional off $conditional = false; $obj->doSmth(13); $obj->doSmth('x');

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)
8.3.60.0090.00918.56
8.3.50.0120.00722.05
8.3.40.0110.00318.97
8.3.30.0090.00618.69
8.3.20.0000.00820.31
8.3.10.0050.00320.69
8.3.00.0000.00723.51
8.2.180.0090.00618.54
8.2.170.0100.01022.96
8.2.160.0120.00622.15
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0080.00020.69
8.2.120.0000.00726.35
8.2.110.0070.00319.32
8.2.100.0040.00817.80
8.2.90.0030.00519.16
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0060.00317.80
8.2.50.0060.00318.09
8.2.40.0060.00322.11
8.2.30.0000.00819.48
8.2.20.0040.00417.88
8.2.10.0040.00418.23
8.2.00.0050.00218.21
8.1.280.0080.00825.92
8.1.270.0090.00022.05
8.1.260.0000.01028.09
8.1.250.0080.00028.09
8.1.240.0030.00622.51
8.1.230.0070.00317.58
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0090.00017.36
8.1.190.0030.00617.35
8.1.180.0060.00318.10
8.1.170.0030.00518.57
8.1.160.0050.00220.73
8.1.150.0060.00318.94
8.1.140.0030.00519.63
8.1.130.0030.00317.75
8.1.120.0040.00417.52
8.1.110.0000.00717.57
8.1.100.0070.00017.51
8.1.90.0040.00417.55
8.1.80.0000.00717.53
8.1.70.0030.00317.51
8.1.60.0000.00817.66
8.1.50.0030.00517.55
8.1.40.0000.00817.59
8.1.30.0000.00817.64
8.1.20.0030.00617.56
8.1.10.0040.00417.64
8.1.00.0040.00417.56
8.0.300.0040.00418.77
8.0.290.0000.00816.88
8.0.280.0070.00018.38
8.0.270.0000.00717.20
8.0.260.0080.00017.33
8.0.250.0070.00017.06
8.0.240.0030.00317.11
8.0.230.0040.00417.05
8.0.220.0050.00316.88
8.0.210.0000.00716.90
8.0.200.0050.00217.06
8.0.190.0040.00416.97
8.0.180.0020.00516.93
8.0.170.0030.00617.02
8.0.160.0000.00716.98
8.0.150.0000.00816.94
8.0.140.0060.00316.98
8.0.130.0000.00613.51
8.0.120.0080.00017.09
8.0.110.0000.00717.05
8.0.100.0090.00016.96
8.0.90.0070.00016.91
8.0.80.0130.00717.05
8.0.70.0000.00716.93
8.0.60.0040.00416.74
8.0.50.0040.00416.77
8.0.30.0110.00817.29
8.0.20.0140.00617.40
8.0.10.0020.00516.95
8.0.00.0120.00716.93
7.4.330.0050.00016.84
7.4.320.0000.00716.40
7.4.300.0000.00616.60
7.4.290.0040.00416.69
7.4.280.0080.00016.54
7.4.270.0000.00716.56
7.4.260.0000.00816.59
7.4.250.0000.00716.47
7.4.240.0000.00716.54
7.4.230.0000.00716.68
7.4.220.0140.01416.68
7.4.210.0100.00416.55
7.4.200.0030.00516.48
7.4.160.0120.00316.62
7.4.150.0120.00917.40
7.4.140.0110.01317.86
7.4.130.0100.00816.62
7.4.120.0050.01316.72
7.4.110.0110.00616.46
7.4.100.0090.00916.50
7.4.90.0120.00616.77
7.4.80.0160.00719.39
7.4.70.0120.00916.74
7.4.60.0100.00616.60
7.4.50.0120.00616.66
7.4.40.0060.01716.41
7.4.30.0050.01416.70
7.4.00.0080.00315.23
7.3.330.0030.00313.33
7.3.320.0000.00713.43
7.3.310.0000.00716.23
7.3.300.0030.00316.40
7.3.290.0050.00316.42
7.3.280.0110.00616.42
7.3.270.0100.00717.40
7.3.260.0090.00916.47
7.3.250.0100.00916.48
7.3.240.0060.01116.53
7.3.230.0170.00016.39
7.3.210.0100.01016.35
7.3.200.0030.01416.38
7.3.190.0050.01016.70
7.3.180.0120.00616.50
7.3.170.0070.01116.43
7.3.160.0040.01316.46
7.2.330.0110.00716.74
7.2.320.0110.00716.75
7.2.310.0000.01716.67
7.2.300.0030.01916.59
7.2.290.0040.01216.77
7.2.60.0100.00317.00
7.2.50.0090.00616.80
7.1.200.0040.01115.86
7.1.70.0000.00817.29
7.1.60.0040.02119.19
7.1.50.0100.01316.98
7.1.00.0030.07722.44
7.0.200.0260.01014.45
7.0.100.0030.08020.17
7.0.90.0070.04719.95
7.0.80.0130.04019.86
7.0.70.0030.07719.86
7.0.60.0100.07719.93
7.0.50.0030.06320.41
7.0.40.0130.07720.08
7.0.30.0100.06720.07
7.0.20.0130.07720.09
7.0.10.0070.08320.06
7.0.00.0030.06720.16
5.6.280.0070.03021.13
5.6.250.0130.07720.58
5.6.240.0130.08020.52
5.6.230.0130.07320.49
5.6.220.0170.04020.70
5.6.210.0170.06720.39
5.6.200.0200.07721.04
5.6.190.0070.08721.13
5.6.180.0100.08020.93
5.6.170.0130.08321.02
5.6.160.0100.08021.13
5.6.150.0070.07721.16
5.6.140.0030.08721.10
5.6.130.0100.08021.16
5.6.120.0070.08020.94
5.6.110.0130.08020.90
5.6.100.0100.06021.00
5.6.90.0070.08320.98
5.6.80.0100.07720.43
5.6.70.0030.06320.39
5.6.60.0030.08720.47
5.6.50.0100.08020.55
5.6.40.0070.07320.40
5.6.30.0130.06320.52
5.6.20.0100.07020.36
5.6.10.0030.06320.37
5.6.00.0130.04020.46
5.5.380.0100.04320.46
5.5.370.0100.06720.37
5.5.360.0100.08320.31
5.5.350.0170.08020.35
5.5.340.0100.07720.88
5.5.330.0100.05020.88
5.5.320.0070.07720.89
5.5.310.0000.09020.85
5.5.300.0070.08320.87
5.5.290.0100.07720.75
5.5.280.0070.08020.89
5.5.270.0130.07720.77
5.5.260.0130.07720.76
5.5.250.0100.06020.64
5.5.240.0030.07720.16
5.5.230.0130.06720.20
5.5.220.0100.07720.20
5.5.210.0070.08720.14
5.5.200.0130.07720.26
5.5.190.0030.06720.26
5.5.180.0030.05720.14
5.5.160.0130.03320.23
5.5.150.0030.06720.16
5.5.140.0070.07320.23
5.5.130.0170.03320.10
5.5.120.0030.08320.22
5.5.110.0030.04720.09
5.5.100.0000.08320.01
5.5.90.0200.06020.04
5.5.80.0130.07320.05
5.5.70.0100.08020.15
5.5.60.0070.05320.02
5.5.50.0200.06320.13
5.5.40.0200.06720.07
5.5.30.0070.04720.02
5.5.20.0170.07720.08
5.5.10.0070.04720.08
5.5.00.0070.07720.01

preferences:
32.93 ms | 401 KiB | 5 Q