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->attributes() !== null and !$element->children(); } $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(true, $documentElement->child[0]['a3']), 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.0150.00417.24
8.3.50.0120.00522.02
8.3.40.0030.01219.04
8.3.30.0110.00319.46
8.3.20.0040.00420.41
8.3.10.0090.00623.77
8.3.00.0030.00519.63
8.2.180.0130.00318.54
8.2.170.0180.00422.96
8.2.160.0070.01120.77
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0100.00326.16
8.2.120.0080.00022.37
8.2.110.0030.00722.45
8.2.100.0110.00418.03
8.2.90.0000.00819.33
8.2.80.0000.00918.18
8.2.70.0000.00817.88
8.2.60.0040.00418.18
8.2.50.0040.00418.07
8.2.40.0000.00818.41
8.2.30.0070.00318.34
8.2.20.0030.00517.98
8.2.10.0080.00018.46
8.2.00.0030.00518.04
8.1.280.0140.01025.92
8.1.270.0060.00324.04
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.93
8.1.230.0090.00319.47
8.1.220.0000.00817.89
8.1.210.0090.00018.77
8.1.200.0090.00017.73
8.1.190.0060.00317.91
8.1.180.0080.00018.10
8.1.170.0000.00818.91
8.1.160.0030.00522.32
8.1.150.0050.00218.88
8.1.140.0030.00517.66
8.1.130.0030.00318.06
8.1.120.0000.00817.82
8.1.110.0040.00417.79
8.1.100.0050.00317.62
8.1.90.0000.00917.80
8.1.80.0030.00317.60
8.1.70.0000.00717.58
8.1.60.0040.00417.79
8.1.50.0040.00417.72
8.1.40.0030.00617.84
8.1.30.0050.00317.94
8.1.20.0000.00817.94
8.1.10.0000.00817.87
8.1.00.0000.00817.71
8.0.300.0000.00718.77
8.0.290.0080.00017.41
8.0.280.0030.00318.67
8.0.270.0000.00717.39
8.0.260.0030.00317.16
8.0.250.0050.00317.16
8.0.240.0050.00317.14
8.0.230.0030.00317.24
8.0.220.0080.00017.20
8.0.210.0040.00417.32
8.0.200.0000.00817.33
8.0.190.0030.00617.21
8.0.180.0040.00417.14
8.0.170.0030.00517.18
8.0.160.0000.00817.13
8.0.150.0040.00417.32
8.0.140.0060.00317.24
8.0.130.0030.00313.75
8.0.120.0000.00817.26
8.0.110.0050.00317.02
8.0.100.0000.00817.27
8.0.90.0050.00217.22
8.0.80.0030.01417.36
8.0.70.0080.00017.04
8.0.60.0030.00517.18
8.0.50.0030.00617.06
8.0.30.0140.00617.21
8.0.20.0080.01317.40
8.0.10.0000.00717.36
8.0.00.0130.00717.07
7.4.330.0000.00515.30
7.4.320.0040.00416.77
7.4.300.0000.00616.86
7.4.290.0060.00616.85
7.4.280.0060.00316.79
7.4.270.0040.00416.90
7.4.260.0030.00316.79
7.4.250.0040.00416.75
7.4.240.0050.00216.93
7.4.230.0070.00016.61
7.4.220.0070.01116.76
7.4.210.0060.00816.85
7.4.200.0030.00416.83
7.4.190.0030.00316.66
7.4.160.0100.00716.63
7.4.150.0090.00917.40
7.4.140.0100.00817.86
7.4.130.0080.00816.70
7.4.120.0100.00716.84
7.4.110.0130.01016.79
7.4.100.0060.01216.77
7.4.90.0090.00916.61
7.4.80.0060.01219.39
7.4.70.0140.00316.95
7.4.60.0060.01216.78
7.4.50.0030.00316.80
7.4.40.0060.01222.77
7.4.30.0100.00716.78
7.4.10.0040.01514.99
7.4.00.0060.00715.16
7.3.330.0060.00013.73
7.3.320.0030.00313.72
7.3.310.0000.00716.83
7.3.300.0000.00716.60
7.3.290.0060.00916.73
7.3.280.0110.00816.73
7.3.270.0070.01017.40
7.3.260.0130.00316.68
7.3.250.0040.01616.81
7.3.240.0150.00316.68
7.3.230.0070.01016.67
7.3.210.0070.01116.95
7.3.200.0110.00719.39
7.3.190.0130.01016.77
7.3.180.0130.00316.92
7.3.170.0030.01416.76
7.3.160.0130.00616.70
7.3.130.0110.00715.21
7.3.120.0060.00915.27
7.3.110.0060.01014.91
7.3.100.0030.01014.95
7.3.90.0080.00514.89
7.3.80.0080.00315.37
7.3.70.0040.00815.01
7.3.60.0030.01415.05
7.3.50.0090.00615.25
7.3.40.0000.01215.22
7.3.30.0030.00614.98
7.3.20.0070.00716.63
7.3.10.0060.00916.68
7.3.00.0060.00616.76
7.2.330.0000.01716.80
7.2.320.0130.00616.97
7.2.310.0070.01417.10
7.2.300.0140.00316.76
7.2.290.0130.01017.12
7.2.260.0100.01015.06
7.2.250.0090.00915.34
7.2.240.0040.01215.10
7.2.230.0100.00715.20
7.2.220.0060.01015.31
7.2.210.0030.00915.29
7.2.200.0120.00315.11
7.2.190.0060.00615.21
7.2.180.0060.01015.13
7.2.170.0060.00915.15
7.2.160.0080.00815.21
7.2.150.0070.01017.18
7.2.140.0000.01717.11
7.2.130.0050.01017.07
7.2.120.0020.01116.82
7.2.110.0070.00617.00
7.2.100.0090.00516.88
7.2.90.0070.00616.93
7.2.80.0080.00516.71
7.2.70.0080.00416.92
7.2.60.0070.00616.97
7.2.50.0090.00517.11
7.2.40.0050.00816.97
7.2.30.0080.00917.07
7.2.20.0050.00916.90
7.2.10.0060.00517.02
7.2.00.0050.00917.71
7.1.330.0070.00715.89
7.1.320.0070.00715.95
7.1.310.0060.00615.85
7.1.300.0040.01115.78
7.1.290.0000.01215.79
7.1.280.0000.01115.91
7.1.270.0040.01016.01
7.1.260.0000.01015.91
7.1.250.0040.00815.80
7.1.240.0080.00615.82
7.1.230.0050.00915.75
7.1.220.0080.00115.80
7.1.210.0080.00315.95
7.1.200.0040.01015.79
7.1.190.0030.01215.74
7.1.180.0030.01015.92
7.1.170.0030.01116.03
7.1.160.0030.00915.74
7.1.150.0070.00315.94
7.1.140.0050.00515.79
7.1.130.0040.00615.92
7.1.120.0030.01115.78
7.1.110.0050.00915.89
7.1.100.0030.01015.75
7.1.90.0020.00815.95
7.1.80.0040.00916.01
7.1.70.0100.00516.50
7.1.60.0060.00916.29
7.1.50.0050.01116.22
7.1.40.0070.00315.91
7.1.30.0070.00515.91
7.1.20.0080.00715.72
7.1.10.0030.00815.77
7.1.00.0040.03118.07
7.0.330.0070.01015.56
7.0.320.0080.00415.43
7.0.310.0050.00515.57
7.0.300.0070.00315.45
7.0.290.0050.00915.75
7.0.280.0100.00315.50
7.0.270.0040.00615.50
7.0.260.0050.00715.52
7.0.250.0050.00615.52
7.0.240.0020.01315.55
7.0.230.0040.00915.63
7.0.220.0030.01115.60
7.0.210.0070.00715.60
7.0.200.0030.01115.99
7.0.190.0030.00815.48
7.0.180.0030.01215.50
7.0.170.0040.01015.43
7.0.160.0020.00915.49
7.0.150.0060.00815.48
7.0.140.0040.03017.75
7.0.130.0040.00715.45
7.0.120.0050.00515.60
7.0.110.0030.00915.29
7.0.100.0090.03216.99
7.0.90.0180.02616.95
7.0.80.0050.01817.04
7.0.70.0030.02017.04
7.0.60.0070.01417.04
7.0.50.0060.03317.18
7.0.40.0050.01915.83
7.0.30.0070.01815.70
7.0.20.0090.03015.70
7.0.10.0040.03315.66
7.0.00.0110.02915.73
5.6.400.0050.00814.75
5.6.390.0130.00014.39
5.6.380.0090.00514.72
5.6.370.0090.00414.78
5.6.360.0080.00314.59
5.6.350.0080.00414.71
5.6.340.0040.01114.63
5.6.330.0080.00814.72
5.6.320.0120.00314.86
5.6.310.0020.01014.64
5.6.300.0080.00614.69
5.6.290.0070.00714.82
5.6.280.0040.03116.78
5.6.270.0030.00914.70
5.6.260.0040.01114.28
5.6.250.0020.03716.73
5.6.240.0090.02716.53
5.6.230.0070.03416.68
5.6.220.0040.02516.68
5.6.210.0050.01916.56
5.6.200.0070.01816.90
5.6.190.0070.01916.65
5.6.180.0030.02016.79
5.6.170.0060.01816.67
5.6.160.0080.03016.79
5.6.150.0040.02216.77
5.6.140.0070.02516.78
5.6.130.0010.02516.80
5.6.120.0030.02016.75
5.6.110.0040.01916.80
5.6.100.0050.02016.84
5.6.90.0040.01916.83
5.6.80.0040.01916.42
5.6.70.0060.02016.57
5.6.60.0020.02216.49
5.6.50.0020.02116.54
5.6.40.0060.02216.50
5.6.30.0070.01516.49
5.6.20.0040.01616.67
5.6.10.0050.01916.46
5.6.00.0080.01716.50
5.5.380.0070.03115.41
5.5.370.0060.02115.46
5.5.360.0050.02115.61
5.5.350.0030.02415.49
5.5.340.0070.01615.54
5.5.330.0020.02015.62
5.5.320.0040.03215.69
5.5.310.0030.02915.66
5.5.300.0070.01815.65
5.5.290.0060.01615.68
5.5.280.0060.01715.72
5.5.270.0070.01715.70
5.5.260.0050.02015.71
5.5.250.0040.02215.61
5.5.240.0050.01715.29
5.5.230.0070.01615.37
5.5.220.0060.01615.31
5.5.210.0030.02115.38
5.5.200.0050.01815.42
5.5.190.0010.02115.41
5.5.180.0060.01415.43
5.5.170.0030.01014.52
5.5.160.0080.01415.18
5.5.150.0040.01815.40
5.5.140.0020.01915.49
5.5.130.0070.01315.38
5.5.120.0030.01715.40
5.5.110.0090.02515.41
5.5.100.0110.02515.41
5.5.90.0060.02915.32
5.5.80.0060.02015.44
5.5.70.0050.03015.35
5.5.60.0080.01815.43
5.5.50.0040.01915.32
5.5.40.0040.02915.35
5.5.30.0050.02815.36
5.5.20.0030.03115.27
5.5.10.0050.01915.36
5.5.00.0050.02015.22
5.4.450.0070.01614.20
5.4.440.0040.01914.09
5.4.430.0060.01414.19
5.4.420.0060.01414.04
5.4.410.0040.02214.04
5.4.400.0030.01913.94
5.4.390.0040.02514.01
5.4.380.0050.01713.98
5.4.370.0030.01813.99
5.4.360.0050.01613.86
5.4.350.0000.02513.90
5.4.340.0050.01614.14
5.4.330.0060.00311.42
5.4.320.0030.02313.98
5.4.310.0040.01613.97
5.4.300.0030.01713.98
5.4.290.0080.01313.89
5.4.280.0060.01413.92
5.4.270.0070.02013.80
5.4.260.0080.02713.98
5.4.250.0090.02514.00
5.4.240.0080.02813.93
5.4.230.0050.01713.81
5.4.220.0020.02513.98
5.4.210.0030.02114.05
5.4.200.0030.02214.03
5.4.190.0060.03113.89
5.4.180.0020.02813.88
5.4.170.0090.02614.02
5.4.160.0070.01613.92
5.4.150.0050.01913.91
5.4.140.0050.02413.15
5.4.130.0050.01913.12
5.4.120.0080.02113.12
5.4.110.0060.01313.22
5.4.100.0020.03113.05
5.4.90.0030.03113.25
5.4.80.0040.01613.03
5.4.70.0040.02713.13
5.4.60.0040.02313.13
5.4.50.0030.02113.09
5.4.40.0100.01413.06
5.4.30.0030.03013.10
5.4.20.0070.01513.13
5.4.10.0050.02413.14
5.4.00.0030.01812.94
5.3.290.0040.01512.40
5.3.280.0070.02912.35
5.3.270.0070.01812.37
5.3.260.0050.02712.36
5.3.250.0070.02812.32
5.3.240.0090.02712.29
5.3.230.0050.02812.36
5.3.220.0070.02512.30
5.3.210.0030.02712.28
5.3.200.0050.02612.31
5.3.190.0060.03112.33
5.3.180.0080.02612.42
5.3.170.0070.02912.41
5.3.160.0070.01712.38
5.3.150.0090.02612.37
5.3.140.0060.02512.37
5.3.130.0060.01812.34
5.3.120.0070.02312.32
5.3.110.0060.02712.35
5.3.100.0070.02612.15
5.3.90.0050.02412.10
5.3.80.0050.02612.13
5.3.70.0030.02412.13
5.3.60.0060.02512.14
5.3.50.0060.02012.18
5.3.40.0090.02012.04
5.3.30.0060.02212.07
5.3.20.0030.01911.98
5.3.10.0050.02311.93
5.3.00.0090.02111.93
5.2.170.0080.02910.52
5.2.160.0060.01810.51
5.2.150.0060.02810.46
5.2.140.0060.03410.38
5.2.130.0020.02510.49
5.2.120.0080.02810.44
5.2.110.0050.03210.38
5.2.100.0040.01710.52
5.2.90.0040.02810.38
5.2.80.0020.02810.42
5.2.70.0050.03210.49
5.2.60.0070.02210.39
5.2.50.0030.03310.44
5.2.40.0060.01810.39
5.2.30.0050.02910.27
5.2.20.0090.01910.22
5.2.10.0020.01910.32
5.2.00.0050.02710.09
5.1.60.0070.0239.49
5.1.50.0060.0289.40
5.1.40.0050.0149.42
5.1.30.0050.0299.71
5.1.20.0050.0249.67
5.1.10.0040.0179.52
5.1.00.0130.0209.50
5.0.50.0040.0209.06
5.0.40.0020.0129.06
5.0.30.0020.0199.06
5.0.20.0020.0269.06
5.0.10.0030.0199.06
5.0.00.0010.0309.06
4.4.90.0030.0209.06
4.4.80.0050.0129.06
4.4.70.0020.0189.06
4.4.60.0030.0189.06
4.4.50.0020.0109.06
4.4.40.0030.0159.06
4.4.30.0060.0159.06
4.4.20.0030.0169.06
4.4.10.0000.0179.06
4.4.00.0020.0309.06
4.3.110.0030.0099.06
4.3.100.0040.0099.06
4.3.90.0060.0139.06
4.3.80.0020.0279.06
4.3.70.0040.0129.06
4.3.60.0030.0159.06
4.3.50.0020.0129.06
4.3.40.0020.0209.06
4.3.30.0020.0179.06
4.3.20.0020.0159.06
4.3.10.0030.0149.06
4.3.00.0020.0189.06

preferences:
46.1 ms | 401 KiB | 5 Q