3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * SimpleXMLElement Introspection */ error_reporting(~0); $xml = '<document> <child> give <grandchild a1="v1" a2="v2"> me </grandchild> <grandchild> more </grandchild> sugar. </child> <child> </child> <single/> </document> '; $simple = new SimpleXMLElement($xml); /** * @param SimpleXMLElement $element * @return bool */ function simplexml_is_attribute(SimpleXMLElement $element) { return $element->xpath('../*') === array(); } $documentElement = $simple; $attributeList = $simple->child->grandchild->attributes(); $attributeListEmpty = $simple->child->attributes(); $attribute = $simple->child->grandchild['a1']; $suite = array( 'is_attribute' => array('simplexml_is_attribute', array( array(true, $attribute), array(false, $attributeList), array(false, $attributeListEmpty), array(false, $documentElement), array(false, $documentElement->child), array(false, $documentElement->child[0]), )), ); echo "Running tests with LIBXML ", LIBXML_DOTTED_VERSION, ":\n"; run_test_suite($suite); function run_test_suite(array $testsuite) { foreach ($testsuite as $caselabel => $testcasedef) { list($callback, $testcase) = $testcasedef; $stats[] = run_testcase($testcase, $callback, $caselabel); } echo "\n"; $stat['tests'] = 0; $stat['failures'] = 0; foreach ($stats as $singled) { $stat['tests'] += $singled['tests']; $stat['failures'] += $singled['failures']; echo $singled['messages']; } printf("Done %d tests with %d failures.", $stat['tests'], $stat['failures']); } function run_testcase(array $testcase, $callback, $label = null) { if ($label === null) $label = $callback; $stats['tests'] = 0; $stats['failures'] = 0; $messages = ''; foreach ($testcase as $i => $test) { list($expected, $subject, $testlabel) = $test + array(2 => "#$i"); $labeltest = $label . ' ' . $testlabel; ob_start(); $result = run_test($expected, $subject, $callback, $labeltest); $buffer = ob_get_clean(); echo $result ? '.' : 'F'; if ($buffer) { $messages .= sprintf("### %s ###\n", $labeltest); $messages .= $buffer; } $stats['tests']++; if (!$result) $stats['failures']++; } return $stats + array('messages' => $messages); } function run_test($expected, $subject, $callback, $label) { $actual = call_user_func($callback, $subject); if ($expected instanceof SimpleXMLElement and $actual instanceof SimpleXMLElement) { $result = $actual == $expected; } else { $result = $actual === $expected; } if (!$result) { $extra = ''; if ($subject instanceof SimpleXMLElement) { $extra = sprintf(' with %s', rtrim($subject->asXML())); } printf("FAILED to test %s%s.\n", $label, $extra); echo 'expected: ', var_dump($expected); echo 'actual:', var_dump($actual); } return $result; }

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.0140.00717.25
8.3.50.0090.00817.84
8.3.40.0150.00419.29
8.3.30.0060.01019.27
8.3.20.0080.00019.07
8.3.10.0060.00320.92
8.3.00.0060.01319.63
8.2.180.0000.01517.25
8.2.170.0150.00022.96
8.2.160.0150.00021.02
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0030.00620.88
8.2.110.0090.00019.81
8.2.100.0110.00018.53
8.2.90.0080.00019.46
8.2.80.0000.00819.84
8.2.70.0030.00618.25
8.2.60.0030.00618.54
8.2.50.0030.00618.13
8.2.40.0060.00318.84
8.2.30.0030.00618.55
8.2.20.0050.00519.88
8.2.10.0080.00018.36
8.2.00.0000.00818.35
8.1.280.0110.00725.92
8.1.270.0040.00423.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0110.00024.10
8.1.230.0100.00621.42
8.1.220.0030.00618.77
8.1.210.0040.00419.37
8.1.200.0030.00717.85
8.1.190.0000.00818.03
8.1.180.0040.00418.10
8.1.170.0080.00019.34
8.1.160.0030.00519.34
8.1.150.0000.00919.06
8.1.140.0040.00417.86
8.1.130.0070.00018.32
8.1.120.0040.00417.96
8.1.110.0050.00317.96
8.1.100.0040.00417.96
8.1.90.0000.00817.80
8.1.80.0040.00417.74
8.1.70.0000.00817.96
8.1.60.0060.00317.86
8.1.50.0050.00317.87
8.1.40.0000.00818.08
8.1.30.0000.00818.21
8.1.20.0030.00518.20
8.1.10.0040.00417.94
8.1.00.0000.00918.05
8.0.300.0040.00420.35
8.0.290.0030.00617.25
8.0.280.0060.00318.91
8.0.270.0030.00517.75
8.0.260.0070.00017.38
8.0.250.0000.00717.55
8.0.240.0080.00017.53
8.0.230.0030.00317.39
8.0.220.0050.00217.45
8.0.210.0050.00317.49
8.0.200.0030.00717.54
8.0.190.0070.00017.50
8.0.180.0000.00717.29
8.0.170.0030.00617.13
8.0.160.0030.00517.27
8.0.150.0030.00517.44
8.0.140.0050.00217.28
8.0.130.0060.00013.95
8.0.120.0040.00417.45
8.0.110.0080.00017.38
8.0.100.0040.00417.46
8.0.90.0040.00417.32
8.0.80.0060.01017.54
8.0.70.0040.00417.38
8.0.60.0040.00417.18
8.0.50.0040.00417.48
8.0.30.0090.00917.82
8.0.20.0110.00817.39
8.0.10.0050.00317.51
8.0.00.0110.00917.30
7.4.330.0000.00513.48
7.4.320.0050.00216.91
7.4.300.0070.00017.02
7.4.290.0070.00017.02
7.4.280.0070.00017.04
7.4.270.0040.00417.00
7.4.260.0050.00013.68
7.4.250.0030.00616.95
7.4.240.0040.00416.91
7.4.230.0030.00416.98
7.4.220.0120.01517.07
7.4.210.0040.01117.09
7.4.200.0050.00317.03
7.4.190.0060.00317.20
7.4.160.0070.01016.93
7.4.150.0080.01116.82
7.4.140.0090.00816.95
7.4.130.0090.00916.97
7.4.120.0110.00617.03
7.4.110.0120.00617.02
7.4.100.0000.01716.96
7.4.90.0060.01717.03
7.4.80.0110.00716.92
7.4.70.0090.00917.07
7.4.60.0120.01217.06
7.4.50.0020.00216.75
7.4.40.0090.00716.92
7.4.30.0110.00617.09
7.4.00.0100.00715.09
7.3.330.0030.00313.57
7.3.320.0000.00513.61
7.3.310.0050.00316.94
7.3.300.0030.00416.81
7.3.290.0050.00916.85
7.3.280.0100.01116.83
7.3.270.0110.00816.87
7.3.260.0140.01117.06
7.3.250.0100.00917.02
7.3.240.0100.01316.84
7.3.230.0070.01017.05
7.3.210.0100.00916.92
7.3.200.0070.01419.39
7.3.190.0080.01417.11
7.3.180.0070.01016.75
7.3.170.0030.01316.79
7.3.160.0100.00716.77
7.3.120.0100.00715.27
7.3.10.0100.00316.83
7.3.00.0110.00416.95
7.2.330.0080.01217.27
7.2.320.0140.00317.16
7.2.310.0130.01317.11
7.2.300.0110.00717.15
7.2.290.0060.01617.36
7.2.130.0090.00616.96
7.2.120.0100.00717.07
7.2.110.0060.00617.14
7.2.100.0000.01616.96
7.2.90.0030.01217.12
7.2.80.0030.00617.17
7.2.70.0090.00617.17
7.2.60.0070.00717.07
7.2.50.0100.00017.27
7.2.40.0090.00617.18
7.2.30.0130.00017.47
7.2.20.0110.00017.10
7.2.10.0080.00817.18
7.2.00.0140.00618.51
7.1.250.0040.01115.94
7.1.200.0030.01016.12
7.1.100.0030.00918.49
7.1.70.0030.00617.11
7.1.60.0100.01019.30
7.1.50.0000.01117.17
7.1.00.0000.08022.49
7.0.200.0460.00414.85
7.0.140.0000.07722.25
7.0.120.0070.07322.28
7.0.60.0070.06020.32
7.0.50.0030.04018.17
7.0.40.0070.06720.50
7.0.30.0600.06720.46
7.0.20.0270.08320.36
7.0.10.0230.06720.27
7.0.00.0030.04320.31
5.6.280.0100.07021.18
5.6.210.0070.08020.86
5.6.200.0030.08318.47
5.6.190.0070.07720.75
5.6.180.0230.07720.68
5.6.170.0230.06020.90
5.6.160.0070.05720.70
5.6.150.0070.07718.43
5.6.140.0070.03718.51
5.6.130.0030.04318.47
5.6.120.0070.08021.27
5.6.110.0070.09021.27
5.6.100.0170.07321.32
5.6.90.0130.05021.32
5.6.80.0030.06020.63
5.6.70.0300.07320.66
5.5.350.0130.08020.64
5.5.340.0070.04718.28
5.5.330.0030.08320.38
5.5.320.0130.04320.47
5.5.310.0230.05320.60
5.5.300.0070.07718.21
5.5.290.0070.05718.14
5.5.280.0030.06021.07
5.5.270.0170.07321.08
5.5.260.0100.04721.04
5.5.250.0000.08320.91
5.5.240.0100.03020.47
5.4.450.0070.03719.57
5.4.440.0030.04019.44
5.4.430.0070.03719.62
5.4.420.0000.04019.82
5.4.410.0030.04319.32
5.4.400.0000.04319.21
5.4.390.0070.07719.41
5.4.380.0030.05019.43
5.4.370.0070.03719.05
5.4.360.0070.03719.12
5.4.350.0030.07019.05
5.4.340.0130.06019.28
5.4.320.0100.05019.25
5.4.310.0100.03319.28
5.4.300.0100.07719.28
5.4.290.0130.07319.35
5.4.280.0230.03019.56
5.4.270.0030.05319.56
5.4.260.0070.07719.41
5.4.250.0130.04019.23
5.4.240.0170.05019.40
5.4.230.0030.05019.40
5.4.220.0100.07319.40
5.4.210.0000.05319.55
5.4.200.0000.05019.50
5.4.190.0070.07719.50
5.4.180.0030.08319.33
5.4.170.0100.07719.39
5.4.160.0100.05719.09
5.4.150.0000.04319.21
5.4.140.0000.04316.58
5.4.130.0100.03316.59
5.4.120.0000.04016.66
5.4.110.0030.04316.65
5.4.100.0170.07016.73
5.4.90.0030.06016.65
5.4.80.0170.04716.70
5.4.70.0070.03716.68
5.4.60.0030.05316.74
5.4.50.0070.07316.55
5.4.40.0170.03316.60
5.4.30.0070.04316.63
5.4.20.0100.07716.60
5.4.10.0070.07016.64
5.4.00.0030.04315.99
5.3.290.0030.05015.02
5.3.280.0130.07714.95
5.3.270.0030.04714.82
5.3.260.0000.04314.88
5.3.250.0030.04014.96
5.3.240.0070.05314.82
5.3.230.0070.03714.82
5.3.220.0130.07314.91
5.3.210.0100.03714.81
5.3.200.0070.07714.78
5.3.190.0230.05014.89
5.3.180.0030.07314.93
5.3.170.0100.04014.86
5.3.160.0100.06714.81
5.3.150.0070.06014.82
5.3.140.0130.06714.85
5.3.130.0030.05314.83
5.3.120.0030.04714.94
5.3.110.0000.08014.89
5.3.100.0030.04014.34
5.3.90.0070.07314.37
5.3.80.0270.06014.32
5.3.70.0070.04314.30
5.3.60.0000.04714.36
5.3.50.0100.04014.33
5.3.40.0130.03714.24
5.3.30.0100.03714.13
5.3.20.0200.06014.06
5.3.10.0070.07313.91
5.3.00.0100.03314.00
5.2.170.0030.06311.33
5.2.160.0070.03311.50
5.2.150.0070.05311.53
5.2.140.0070.05011.54
5.2.130.0070.05711.46
5.2.120.0170.02311.40
5.2.110.0000.04711.41
5.2.100.0000.03311.39
5.2.90.0130.03311.39
5.2.80.0030.06311.27
5.2.70.0130.05711.45
5.2.60.0000.04011.45
5.2.50.0000.03311.37
5.2.40.0000.03311.28
5.2.30.0030.05011.27
5.2.20.0070.03011.31
5.2.10.0070.02711.27
5.2.00.0030.06311.00
5.1.60.0030.05310.25
5.1.50.0030.04310.38
5.1.40.0100.02010.23
5.1.30.0030.06310.63
5.1.20.0030.03010.66
5.1.10.0000.06310.36
5.1.00.0100.05010.38
5.0.50.0000.0338.54
5.0.40.0000.0338.58
5.0.30.0000.0508.29
5.0.20.0000.0378.25
5.0.10.0030.0208.34
5.0.00.0000.0378.13
4.4.90.0000.0277.79
4.4.80.0030.0177.79
4.4.70.0000.0307.79
4.4.60.0000.0377.79
4.4.50.0000.0237.79
4.4.40.0030.0437.79
4.4.30.0030.0177.79
4.4.20.0030.0307.79
4.4.10.0030.0277.79
4.4.00.0000.0307.79
4.3.110.0030.0337.79
4.3.100.0100.0277.79
4.3.90.0030.0137.79
4.3.80.0000.0607.79
4.3.70.0030.0377.79
4.3.60.0070.0307.79
4.3.50.0030.0377.79
4.3.40.0070.0537.79
4.3.30.0030.0377.79
4.3.20.0030.0307.79
4.3.10.0000.0277.79
4.3.00.0000.0207.79

preferences:
49.18 ms | 401 KiB | 5 Q