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_element(SimpleXMLElement $element) { list($elementNode) = $element->xpath('.'); return $elementNode == $element; } $documentElement = $simple; $attributeList = $simple->child->grandchild->attributes(); $attributeListEmpty = $simple->child->attributes(); $attribute = $simple->child->grandchild['a1']; $suite = array( 'is_element' => array('simplexml_is_element', array( array(false, $attribute), array(false, $attributeList), array(false, $attributeListEmpty), array(true, $documentElement), array(false, $documentElement->child), array(true, $documentElement->child[0]), array(true, $documentElement->child[1]), array(false, $documentElement->single), array(true, $documentElement->single[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.0160.00718.55
8.3.50.0160.00422.36
8.3.40.0120.00319.14
8.3.30.0070.00719.50
8.3.20.0030.00620.66
8.3.10.0030.00522.63
8.3.00.0000.00821.04
8.2.180.0070.00717.13
8.2.170.0140.00422.96
8.2.160.0110.00419.79
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0110.00726.16
8.2.120.0030.00619.88
8.2.110.0100.00021.02
8.2.100.0060.01218.47
8.2.90.0060.00319.80
8.2.80.0030.00618.43
8.2.70.0090.00018.00
8.2.60.0000.00818.43
8.2.50.0040.00418.13
8.2.40.0040.00420.51
8.2.30.0040.00418.74
8.2.20.0060.00318.28
8.2.10.0030.00618.27
8.2.00.0090.00018.30
8.1.280.0150.00625.92
8.1.270.0040.01522.67
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0090.00021.46
8.1.230.0080.00419.50
8.1.220.0030.00618.29
8.1.210.0080.00018.77
8.1.200.0040.00717.86
8.1.190.0040.00418.01
8.1.180.0030.00719.30
8.1.170.0030.00619.02
8.1.160.0000.00722.67
8.1.150.0060.00319.14
8.1.140.0000.01218.02
8.1.130.0070.00018.22
8.1.120.0050.00317.86
8.1.110.0060.00317.94
8.1.100.0070.00018.09
8.1.90.0000.00717.89
8.1.80.0090.00017.88
8.1.70.0040.00417.85
8.1.60.0000.00817.98
8.1.50.0090.00018.00
8.1.40.0060.00318.12
8.1.30.0040.00418.25
8.1.20.0090.00018.23
8.1.10.0080.00018.02
8.1.00.0080.00018.16
8.0.300.0040.00418.77
8.0.290.0040.00417.80
8.0.280.0020.00518.99
8.0.270.0000.00817.86
8.0.260.0000.00717.36
8.0.250.0030.00317.43
8.0.240.0000.00717.48
8.0.230.0020.00517.59
8.0.220.0000.00717.58
8.0.210.0030.00317.32
8.0.200.0040.00417.46
8.0.190.0000.00817.36
8.0.180.0040.00717.57
8.0.170.0060.00317.36
8.0.160.0050.00217.62
8.0.150.0000.00817.49
8.0.140.0040.00417.49
8.0.130.0060.00013.90
8.0.120.0040.00417.28
8.0.110.0030.00617.32
8.0.100.0020.00517.47
8.0.90.0030.00517.23
8.0.80.0030.01317.40
8.0.70.0040.00417.33
8.0.60.0050.00217.41
8.0.50.0050.00317.29
8.0.30.0100.01017.45
8.0.20.0110.01017.69
8.0.10.0030.00617.59
8.0.00.0160.00617.27
7.4.330.0000.00515.39
7.4.320.0060.00017.07
7.4.300.0000.00817.03
7.4.290.0000.00817.02
7.4.280.0050.00317.01
7.4.270.0040.00417.00
7.4.260.0040.00417.02
7.4.250.0040.00417.09
7.4.240.0060.00217.11
7.4.230.0070.00017.16
7.4.220.0030.01817.23
7.4.210.0070.00917.03
7.4.200.0000.00717.00
7.4.190.0000.00717.29
7.4.160.0160.00017.00
7.4.150.0090.00917.40
7.4.140.0120.00917.86
7.4.130.0070.01017.13
7.4.120.0110.00617.05
7.4.110.0100.01016.96
7.4.100.0140.00417.08
7.4.90.0060.01217.18
7.4.80.0130.00719.39
7.4.70.0000.01817.02
7.4.60.0160.00317.03
7.4.50.0060.00316.89
7.4.40.0040.01222.77
7.4.30.0100.01316.89
7.4.10.0130.00715.27
7.4.00.0110.00615.09
7.3.330.0050.00013.86
7.3.320.0000.00613.86
7.3.310.0050.00216.65
7.3.300.0080.00016.75
7.3.290.0030.01016.93
7.3.280.0110.00916.92
7.3.270.0060.01117.40
7.3.260.0160.00916.98
7.3.250.0140.00517.02
7.3.240.0150.00317.07
7.3.230.0060.01817.03
7.3.210.0070.01116.93
7.3.200.0170.00319.39
7.3.190.0170.00716.89
7.3.180.0140.00616.86
7.3.170.0170.00017.05
7.3.160.0070.01017.12
7.3.130.0030.01415.25
7.3.120.0030.01315.16
7.3.110.0130.00614.99
7.3.100.0120.00315.27
7.3.90.0070.00715.05
7.3.80.0060.00615.19
7.3.70.0080.01215.11
7.3.60.0030.00715.33
7.3.50.0030.00615.48
7.3.40.0000.01215.14
7.3.30.0090.00615.14
7.3.20.0060.00916.68
7.3.10.0070.00816.94
7.3.00.0130.00116.95
7.2.330.0070.01117.20
7.2.320.0040.01316.95
7.2.310.0060.01817.04
7.2.300.0100.00717.12
7.2.290.0070.01017.26
7.2.260.0110.00715.32
7.2.250.0070.01115.43
7.2.240.0120.00615.54
7.2.230.0120.00615.39
7.2.220.0080.00415.03
7.2.210.0030.01015.50
7.2.200.0080.00815.21
7.2.190.0000.01515.23
7.2.180.0030.01315.33
7.2.170.0060.00615.29
7.2.160.0060.01015.39
7.2.150.0000.01317.05
7.2.140.0070.00717.00
7.2.130.0030.01217.21
7.2.120.0060.00817.01
7.2.110.0060.00816.94
7.2.100.0060.00817.05
7.2.90.0050.01016.81
7.2.80.0070.01017.02
7.2.70.0050.00817.19
7.2.60.0050.00817.00
7.2.50.0030.01017.09
7.2.40.0080.00817.21
7.2.30.0090.00717.17
7.2.20.0110.00517.22
7.2.10.0080.00516.96
7.2.00.0030.01018.08
7.1.330.0070.00715.84
7.1.320.0070.00716.13
7.1.310.0080.00816.12
7.1.300.0040.01116.02
7.1.290.0080.00316.31
7.1.280.0080.00815.80
7.1.270.0100.00016.12
7.1.260.0030.01415.85
7.1.250.0040.01315.82
7.1.240.0040.00416.08
7.1.230.0040.00415.90
7.1.220.0030.01115.99
7.1.210.0120.00315.87
7.1.200.0060.00715.93
7.1.190.0030.01015.76
7.1.180.0050.00516.09
7.1.170.0130.00315.79
7.1.160.0060.00915.87
7.1.150.0060.01015.93
7.1.140.0000.01616.08
7.1.130.0030.01415.95
7.1.120.0000.01515.75
7.1.110.0120.00316.18
7.1.100.0050.00617.30
7.1.90.0060.00616.03
7.1.80.0060.00615.76
7.1.70.0050.00816.82
7.1.60.0080.01117.99
7.1.50.0090.00316.80
7.1.40.0090.00016.06
7.1.30.0070.00716.06
7.1.20.0090.00415.90
7.1.10.0030.01016.09
7.1.00.0040.04219.28
7.0.330.0050.00515.65
7.0.320.0060.00615.09
7.0.310.0080.00515.47
7.0.300.0070.00715.63
7.0.290.0100.00615.57
7.0.280.0030.01015.74
7.0.270.0120.00315.79
7.0.260.0000.01315.57
7.0.250.0070.00715.63
7.0.240.0130.00315.84
7.0.230.0100.00315.70
7.0.220.0040.00415.66
7.0.210.0000.01515.62
7.0.200.0080.00416.35
7.0.190.0040.00715.93
7.0.180.0070.00415.73
7.0.170.0110.00415.63
7.0.160.0080.00515.59
7.0.150.0030.00615.70
7.0.140.0090.03619.00
7.0.130.0030.00615.71
7.0.120.0080.00415.71
7.0.110.0000.01215.68
7.0.100.0000.05118.00
7.0.90.0050.03918.04
7.0.80.0080.02618.05
7.0.70.0100.04017.97
7.0.60.0230.04618.18
7.0.50.0070.04518.19
7.0.40.0100.04516.99
7.0.30.0070.02717.12
7.0.20.0030.04217.01
7.0.10.0070.03317.17
7.0.00.0080.04316.92
5.6.400.0040.01114.51
5.6.390.0000.01314.78
5.6.380.0070.00714.75
5.6.370.0060.00315.05
5.6.360.0100.00714.60
5.6.350.0000.01214.76
5.6.340.0100.00014.71
5.6.330.0000.00915.05
5.6.320.0090.00615.05
5.6.310.0090.00614.73
5.6.300.0040.00714.86
5.6.290.0040.00714.58
5.6.280.0030.04017.96
5.6.270.0040.00814.49
5.6.260.0070.00714.80
5.6.250.0110.03817.84
5.6.240.0080.04317.74
5.6.230.0090.04417.84
5.6.220.0060.04117.77
5.6.210.0050.04817.92
5.6.200.0080.04718.05
5.6.190.0100.04317.89
5.6.180.0120.03717.97
5.6.170.0100.04518.02
5.6.160.0030.04818.03
5.6.150.0070.04518.22
5.6.140.0070.03017.98
5.6.130.0070.03817.96
5.6.120.0060.04817.96
5.6.110.0140.04117.92
5.6.100.0030.04517.94
5.6.90.0130.04217.92
5.6.80.0050.04617.66
5.6.70.0100.03517.61
5.6.60.0070.03617.81
5.6.50.0050.04517.71
5.6.40.0070.04217.80
5.6.30.0180.03117.69
5.6.20.0060.04317.61
5.6.10.0110.03517.58
5.6.00.0080.04217.58
5.5.380.0100.02717.63
5.5.370.0090.02917.72
5.5.360.0050.04517.70
5.5.350.0080.04117.47
5.5.340.0140.03717.80
5.5.330.0050.04417.88
5.5.320.0020.05017.62
5.5.310.0070.04317.55
5.5.300.0060.03617.63
5.5.290.0070.04817.82
5.5.280.0090.04417.85
5.5.270.0120.04317.73
5.5.260.0060.04517.93
5.5.250.0060.05317.75
5.5.240.0080.04817.55
5.5.230.0090.03417.53
5.5.220.0080.03717.52
5.5.210.0120.04017.52
5.5.200.0110.04017.55
5.5.190.0110.04617.60
5.5.180.0100.02717.47
5.5.170.0040.01114.52
5.5.160.0080.04517.39
5.5.150.0080.04817.47
5.5.140.0130.03817.34
5.5.130.0060.03817.38
5.5.120.0080.04217.54
5.5.110.0100.03817.36
5.5.100.0100.04317.50
5.5.90.0110.03117.35
5.5.80.0100.03017.45
5.5.70.0110.02017.16
5.5.60.0070.02217.33
5.5.50.0100.02117.40
5.5.40.0110.02017.38
5.5.30.0070.02517.28
5.5.20.0060.02617.32
5.5.10.0020.02517.56
5.5.00.0080.02117.31
5.4.450.0100.02915.74
5.4.440.0060.02915.69
5.4.430.0060.04115.53
5.4.420.0110.04015.53
5.4.410.0030.04115.45
5.4.400.0050.02515.50
5.4.390.0070.04115.48
5.4.380.0050.04015.43
5.4.370.0050.02715.19
5.4.360.0100.04015.12
5.4.350.0070.04115.45
5.4.340.0110.03915.10
5.4.330.0040.00711.20
5.4.320.0050.03015.40
5.4.310.0030.04015.40
5.4.300.0050.04315.40
5.4.290.0100.03815.20
5.4.280.0040.04215.25
5.4.270.0050.04115.42
5.4.260.0100.03515.27
5.4.250.0030.04315.43
5.4.240.0050.02415.34
5.4.230.0060.02315.42
5.4.220.0050.02315.45
5.4.210.0050.02015.33
5.4.200.0050.02015.49
5.4.190.0050.02615.38
5.4.180.0050.02215.45
5.4.170.0060.01815.29
5.4.160.0030.02215.33
5.4.150.0060.03415.41
5.4.140.0000.04814.01
5.4.130.0080.03814.07
5.4.120.0080.01814.02
5.4.110.0060.02114.03
5.4.100.0030.02013.95
5.4.90.0030.02414.14
5.4.80.0020.02013.98
5.4.70.0070.01814.14
5.4.60.0050.02414.12
5.4.50.0070.01814.08
5.4.40.0030.02314.13
5.4.30.0030.03513.99
5.4.20.0070.01513.99
5.4.10.0000.02413.91
5.4.00.0090.02413.85
5.3.290.0080.04312.98
5.3.280.0070.02712.86
5.3.270.0050.02213.07
5.3.260.0020.02612.92
5.3.250.0030.02812.95
5.3.240.0020.02512.90
5.3.230.0020.02312.91
5.3.220.0070.04012.86
5.3.210.0010.02412.86
5.3.200.0040.03712.85
5.3.190.0070.02012.91
5.3.180.0030.02013.01
5.3.170.0020.02512.96
5.3.160.0040.02212.93
5.3.150.0030.02212.88
5.3.140.0030.02812.85
5.3.130.0050.03112.91
5.3.120.0030.02312.93
5.3.110.0030.02412.94
5.3.100.0060.02012.70
5.3.90.0080.01812.57
5.3.80.0050.01912.45
5.3.70.0020.02212.56
5.3.60.0070.01812.65
5.3.50.0020.02112.61
5.3.40.0060.02012.70
5.3.30.0050.02012.67
5.3.20.0060.02012.38
5.3.10.0100.02212.26
5.3.00.0000.02512.39
5.2.170.0030.02711.40
5.2.160.0030.02711.55
5.2.150.0000.03011.56
5.2.140.0000.03311.40
5.2.130.0070.02711.43
5.2.120.0000.03011.51
5.2.110.0100.02711.34
5.2.100.0000.03311.36
5.2.90.0000.03011.54
5.2.80.0100.04711.31
5.2.70.0000.03011.45
5.2.60.0030.02711.41
5.2.50.0000.03011.44
5.2.40.0030.02711.22
5.2.30.0000.03011.29
5.2.20.0000.03011.37
5.2.10.0070.02011.10
5.2.00.0000.03011.08
5.1.60.0070.02010.36
5.1.50.0030.02710.46
5.1.40.0000.02710.36
5.1.30.0070.02710.72
5.1.20.0030.02710.68
5.1.10.0000.02710.40
5.1.00.0030.02710.46
5.0.50.0030.04310.17
5.0.40.0030.04710.17
5.0.30.0030.06710.17
5.0.20.0070.03010.17
5.0.10.0030.03310.17
5.0.00.0000.03710.17
4.4.90.0000.02010.17
4.4.80.0000.01710.17
4.4.70.0000.01710.17
4.4.60.0000.01710.17
4.4.50.0000.01310.17
4.4.40.0000.02710.17
4.4.30.0000.02010.17
4.4.20.0000.01710.17
4.4.10.0030.03010.17
4.4.00.0030.03010.17
4.3.110.0030.03310.17
4.3.100.0000.03010.17
4.3.90.0000.03310.17
4.3.80.0030.05310.17
4.3.70.0030.03010.17
4.3.60.0070.02310.17
4.3.50.0030.03310.17
4.3.40.0000.02710.17
4.3.30.0000.03010.17
4.3.20.0000.02010.17
4.3.10.0000.02310.17
4.3.00.0030.01310.17

preferences:
53.4 ms | 401 KiB | 5 Q