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_attributes(SimpleXMLElement $element) { return $element->attributes() === NULL; } $documentElement = $simple; $attributeList = $simple->child->grandchild->attributes(); $attributeListEmpty = $simple->child->attributes(); $attribute = $simple->child->grandchild['a1']; $suite = array( 'is_attributes' => array('simplexml_is_attributes', array( array(false, $attribute), array(true, $attributeList), array(true, $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.0100.00618.68
8.3.50.0100.00722.24
8.3.40.0040.01119.09
8.3.30.0090.00919.10
8.3.20.0040.00419.10
8.3.10.0050.00319.72
8.3.00.0080.00023.86
8.2.180.0090.00617.00
8.2.170.0090.00622.96
8.2.160.0090.00620.64
8.2.150.0040.00424.18
8.2.140.0070.00324.66
8.2.130.0070.00026.16
8.2.120.0050.00321.25
8.2.110.0050.00522.33
8.2.100.0000.01218.09
8.2.90.0030.00619.65
8.2.80.0090.00018.18
8.2.70.0040.00417.88
8.2.60.0000.00918.30
8.2.50.0040.00418.07
8.2.40.0040.00418.47
8.2.30.0040.00421.44
8.2.20.0040.00418.08
8.2.10.0030.00518.03
8.2.00.0040.00418.10
8.1.280.0090.00625.92
8.1.270.0060.00323.99
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00324.06
8.1.230.0080.00421.16
8.1.220.0040.00418.77
8.1.210.0000.00819.06
8.1.200.0080.00417.48
8.1.190.0000.00817.77
8.1.180.0030.00618.10
8.1.170.0030.00518.75
8.1.160.0000.00719.16
8.1.150.0060.00318.82
8.1.140.0060.00317.75
8.1.130.0050.00218.07
8.1.120.0040.00417.79
8.1.110.0040.00417.66
8.1.100.0050.00317.74
8.1.90.0040.00417.57
8.1.80.0030.00617.72
8.1.70.0050.00317.63
8.1.60.0090.00017.88
8.1.50.0040.00417.66
8.1.40.0040.00417.83
8.1.30.0000.00817.90
8.1.20.0030.00517.70
8.1.10.0040.00417.90
8.1.00.0080.00017.79
8.0.300.0030.00620.10
8.0.290.0040.00417.18
8.0.280.0030.00318.70
8.0.270.0000.00717.50
8.0.260.0030.00317.11
8.0.250.0000.00717.23
8.0.240.0000.00917.17
8.0.230.0030.00317.29
8.0.220.0070.00317.13
8.0.210.0080.00017.07
8.0.200.0060.00017.30
8.0.190.0070.00017.19
8.0.180.0030.00617.18
8.0.170.0040.00417.11
8.0.160.0040.00417.13
8.0.150.0070.00017.11
8.0.140.0000.00717.13
8.0.130.0000.00613.68
8.0.120.0040.00417.16
8.0.110.0000.00817.02
8.0.100.0040.00417.30
8.0.90.0000.00817.21
8.0.80.0090.00617.14
8.0.70.0050.00317.11
8.0.60.0000.00817.29
8.0.50.0040.00417.16
8.0.30.0060.01217.29
8.0.20.0100.01017.41
8.0.10.0030.00517.23
8.0.00.0060.01117.10
7.4.330.0030.00315.01
7.4.320.0060.00016.86
7.4.300.0070.00016.80
7.4.290.0000.00716.77
7.4.280.0070.00016.73
7.4.270.0070.00016.88
7.4.260.0000.00513.49
7.4.250.0060.00316.88
7.4.240.0040.00416.68
7.4.230.0030.00316.95
7.4.220.0040.01616.73
7.4.210.0080.00816.80
7.4.200.0000.00716.75
7.4.190.0000.00816.63
7.4.160.0130.00316.86
7.4.150.0150.01517.40
7.4.140.0090.00917.86
7.4.130.0100.01016.79
7.4.120.0140.00616.84
7.4.110.0140.00416.73
7.4.100.0100.00716.86
7.4.90.0100.00716.73
7.4.80.0080.01119.39
7.4.70.0170.00016.68
7.4.60.0100.01316.78
7.4.50.0050.00516.91
7.4.40.0100.00622.52
7.4.30.0050.01116.66
7.4.00.0030.00714.92
7.3.330.0000.00513.63
7.3.320.0030.00313.65
7.3.310.0030.00316.66
7.3.300.0000.00716.67
7.3.290.0060.00816.67
7.3.280.0120.00516.60
7.3.270.0100.00717.40
7.3.260.0130.00618.24
7.3.250.0110.00816.81
7.3.240.0030.01416.91
7.3.230.0140.00416.68
7.3.210.0100.01316.59
7.3.200.0140.00419.39
7.3.190.0030.01316.84
7.3.180.0110.00416.64
7.3.170.0110.01116.67
7.3.160.0060.01116.80
7.3.120.0030.01215.12
7.3.10.0070.01016.54
7.3.00.0080.00716.52
7.2.330.0130.01916.76
7.2.320.0040.01616.81
7.2.310.0030.01616.72
7.2.300.0070.01017.03
7.2.290.0060.01216.84
7.2.130.0100.00716.82
7.2.120.0070.01016.83
7.2.110.0130.00716.82
7.2.100.0090.00916.86
7.2.90.0090.00816.89
7.2.80.0090.00916.78
7.2.70.0110.00416.79
7.2.60.0080.01016.80
7.2.50.0060.01116.77
7.2.40.0140.00816.92
7.2.30.0140.00917.05
7.2.20.0090.00716.78
7.2.10.0120.00816.81
7.2.00.0080.00817.62
7.1.250.0030.01215.71
7.1.200.0030.00715.84
7.1.100.0040.00718.47
7.1.70.0090.00617.25
7.1.60.0060.01919.40
7.1.50.0100.01317.08
7.1.00.0070.05722.64
7.0.200.0050.00517.05
7.0.140.0130.06722.06
7.0.70.0000.08021.72
7.0.60.0170.05021.78
7.0.50.0000.04322.21
7.0.40.0030.04320.15
7.0.30.0030.04020.07
7.0.20.0000.03720.27
7.0.10.0000.04020.15
7.0.00.0000.04020.14
5.6.280.0000.07721.09
5.6.220.0100.06720.55
5.6.210.0070.07720.58
5.6.200.0030.04321.21
5.6.190.0070.04021.19
5.6.180.0000.04321.07
5.6.170.0000.03721.19
5.6.160.0070.03021.15
5.6.150.0000.03721.18
5.6.140.0030.04021.21
5.6.130.0070.04021.29
5.6.120.0000.04721.13
5.6.110.0030.04321.30
5.6.100.0000.03321.25
5.6.90.0070.03021.22
5.6.80.0000.04020.67
5.6.70.0000.03320.57
5.6.60.0000.03320.57
5.6.50.0070.02720.70
5.6.40.0000.03320.57
5.6.30.0030.03020.42
5.6.20.0000.03320.67
5.6.10.0100.02320.55
5.6.00.0030.03020.51
5.5.360.0070.08320.45
5.5.350.0130.07320.48
5.5.340.0030.04020.80
5.5.330.0030.04021.03
5.5.320.0000.04321.04
5.5.310.0070.03020.89
5.5.300.0000.04021.05
5.5.290.0030.04021.05
5.5.280.0030.03321.07
5.5.270.0000.04721.02
5.5.260.0000.04020.82
5.5.250.0070.03020.74
5.5.240.0070.02720.47
5.5.230.0000.03320.24
5.5.220.0070.02720.41
5.5.210.0030.03020.37
5.5.200.0000.03320.34
5.5.190.0000.03320.44
5.5.180.0000.03320.32
5.5.160.0030.03020.27
5.5.150.0030.03020.45
5.5.140.0030.04020.45
5.5.130.0030.05720.41
5.5.120.0030.03320.43
5.5.110.0070.04720.31
5.5.100.0000.03320.16
5.5.90.0000.03720.16
5.5.80.0100.03020.29
5.5.70.0030.06020.18
5.5.60.0000.08020.06
5.5.50.0000.07720.28
5.5.40.0100.07020.30
5.5.30.0070.07320.14
5.5.20.0000.07720.14
5.5.10.0000.08320.14
5.5.00.0000.07720.25
5.4.450.0030.04319.61
5.4.440.0030.03319.28
5.4.430.0000.04319.37
5.4.420.0030.03019.52
5.4.410.0030.03019.32
5.4.400.0000.03019.27
5.4.390.0000.03318.93
5.4.380.0000.03019.27
5.4.370.0000.03019.28
5.4.360.0070.02719.26
5.4.350.0030.03019.26
5.4.340.0030.03019.13
5.4.320.0000.03719.13
5.4.310.0000.04019.04
5.4.300.0000.03719.23
5.4.290.0000.03719.04
5.4.280.0000.04019.23
5.4.270.0000.03719.04
5.4.260.0000.03018.95
5.4.250.0170.06319.20
5.4.240.0000.07319.26
5.4.230.0000.07719.12
5.4.220.0000.07719.23
5.4.210.0000.07319.23
5.4.200.0000.03718.95
5.4.190.0030.07719.23
5.4.180.0070.04719.04
5.4.170.0030.07319.20
5.4.160.0000.07719.11
5.4.150.0000.08319.27
5.4.140.0030.07316.50
5.4.130.0000.07716.57
5.4.120.0070.06016.60
5.4.110.0030.07016.59
5.4.100.0070.07016.47
5.4.90.0070.04716.59
5.4.80.0030.07316.66
5.4.70.0070.07316.50
5.4.60.0030.06316.50
5.4.50.0070.06016.53
5.4.40.0030.05716.51
5.4.30.0030.07316.50
5.4.20.0070.05016.59
5.4.10.0000.07716.54
5.4.00.0130.06016.02
5.3.290.0000.04314.75
5.3.280.0070.07014.85
5.3.270.0000.08314.71
5.3.260.0030.07014.87
5.3.250.0030.05714.65
5.3.240.0000.07314.64
5.3.230.0100.07014.77
5.3.220.0100.07014.74
5.3.210.0030.07314.85
5.3.200.0000.06714.74
5.3.190.0030.03714.65
5.3.180.0100.05714.83
5.3.170.0030.07314.61
5.3.160.0070.05314.64
5.3.150.0000.07314.74
5.3.140.0030.07014.74
5.3.130.0030.07714.83
5.3.120.0030.05714.80
5.3.110.0070.07014.81
5.3.100.0000.07714.15
5.3.90.0000.08014.27
5.3.80.0000.07314.02
5.3.70.0100.05714.05
5.3.60.0030.07714.01
5.3.50.0000.06313.96
5.3.40.0030.06714.13
5.3.30.0000.07714.19
5.3.20.0000.05313.71
5.3.10.0070.07313.91
5.3.00.0030.04713.74
5.2.170.0000.06011.39
5.2.160.0070.05311.32
5.2.150.0000.05311.25
5.2.140.0000.05011.32
5.2.130.0000.03011.21
5.2.120.0030.06011.21
5.2.110.0100.05011.11
5.2.100.0030.04011.10
5.2.90.0000.05311.41
5.2.80.0000.03011.39
5.2.70.0000.03011.34
5.2.60.0000.03011.23
5.2.50.0030.06011.22
5.2.40.0000.03311.18
5.2.30.0030.06011.27
5.2.20.0000.06311.17
5.2.10.0000.04010.97
5.2.00.0030.04010.83
5.1.60.0030.04710.10
5.1.50.0030.05010.29
5.1.40.0030.05710.15
5.1.30.0000.05710.59
5.1.20.0000.06010.66
5.1.10.0030.06010.23
5.1.00.0070.05310.25
5.0.50.0030.0439.36
5.0.40.0100.0339.36
5.0.30.0000.0639.36
5.0.20.0100.0409.36
5.0.10.0030.0409.36
5.0.00.0000.0609.36
4.4.90.0000.0339.36
4.4.80.0000.0279.36
4.4.70.0000.0339.36
4.4.60.0000.0209.36
4.4.50.0000.0309.36
4.4.40.0000.0539.36
4.4.30.0070.0279.36
4.4.20.0000.0339.36
4.4.10.0000.0339.36
4.4.00.0030.0509.36
4.3.110.0000.0379.36
4.3.100.0030.0379.36
4.3.90.0000.0379.36
4.3.80.0030.0509.36
4.3.70.0030.0339.36
4.3.60.0030.0379.36
4.3.50.0000.0339.36
4.3.40.0100.0439.36
4.3.30.0030.0339.36
4.3.20.0000.0379.36
4.3.10.0070.0339.36
4.3.00.0000.0309.36

preferences:
61.81 ms | 401 KiB | 5 Q