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 string */ function simplexml_get_xml_without_declaration(SimpleXMLElement $element) { list($elementNode) = $element->xpath('.'); list($documentElement) = $element->xpath('/*'); $xml = $element->asXML(); if ($elementNode == $element and $documentElement == $element) { list(, $xml) = explode("\n", $xml, 2); } return $xml; } $documentElement = $simple; $attributeList = $simple->child->grandchild->attributes(); $attributeListEmpty = $simple->child->attributes(); $attribute = $simple->child->grandchild['a1']; $suite = array( 'get_xml_nodecl' => array('simplexml_get_xml_without_declaration', array( array($xml, $simple), array($simple->child->asXML(), $simple->child), )), ); 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.0120.00318.62
8.3.50.0080.00822.29
8.3.40.0150.00319.34
8.3.30.0120.00919.39
8.3.20.0040.00419.15
8.3.10.0070.00719.71
8.3.00.0050.00324.03
8.2.180.0170.00716.88
8.2.170.0140.00722.96
8.2.160.0140.00020.97
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0050.00326.16
8.2.120.0080.00020.05
8.2.110.0100.00019.59
8.2.100.0080.00418.28
8.2.90.0000.00818.25
8.2.80.0080.00019.35
8.2.70.0030.00518.00
8.2.60.0030.00618.25
8.2.50.0040.00418.00
8.2.40.0000.00920.57
8.2.30.0000.00818.48
8.2.20.0050.00318.21
8.2.10.0030.00518.19
8.2.00.0060.00318.17
8.1.280.0140.00425.92
8.1.270.0090.00023.99
8.1.260.0110.00426.35
8.1.250.0030.00728.09
8.1.240.0060.00324.23
8.1.230.0120.00023.13
8.1.220.0030.00619.07
8.1.210.0000.00818.77
8.1.200.0000.00817.85
8.1.190.0030.00517.73
8.1.180.0040.00418.10
8.1.170.0110.00019.32
8.1.160.0050.00319.29
8.1.150.0030.00619.08
8.1.140.0030.00617.82
8.1.130.0000.00718.29
8.1.120.0030.00717.98
8.1.110.0000.00917.98
8.1.100.0020.00517.71
8.1.90.0040.00417.72
8.1.80.0020.00517.87
8.1.70.0030.00317.84
8.1.60.0030.00518.01
8.1.50.0040.00418.00
8.1.40.0000.00918.04
8.1.30.0000.00918.18
8.1.20.0030.00518.14
8.1.10.0040.00418.07
8.1.00.0030.00517.93
8.0.300.0080.00018.77
8.0.290.0040.00417.25
8.0.280.0030.00318.84
8.0.270.0070.00018.43
8.0.260.0030.00717.30
8.0.250.0030.00517.31
8.0.240.0040.00417.23
8.0.230.0000.00717.53
8.0.220.0000.00717.37
8.0.210.0000.00717.49
8.0.200.0070.00017.55
8.0.190.0040.00417.55
8.0.180.0040.00417.51
8.0.170.0040.00417.51
8.0.160.0050.00217.34
8.0.150.0000.00717.44
8.0.140.0000.00817.46
8.0.130.0000.00613.92
8.0.120.0080.00017.31
8.0.110.0050.00317.42
8.0.100.0040.00417.38
8.0.90.0080.00017.47
8.0.80.0090.01217.34
8.0.70.0050.00217.25
8.0.60.0030.00517.19
8.0.50.0000.00817.43
8.0.30.0180.00617.50
8.0.20.0130.00917.78
8.0.10.0080.00017.40
8.0.00.0120.00917.32
7.4.330.0030.00315.10
7.4.320.0060.00016.87
7.4.300.0000.00716.99
7.4.290.0040.00416.89
7.4.280.0070.00016.87
7.4.270.0070.00017.10
7.4.260.0000.00513.73
7.4.250.0040.00417.01
7.4.240.0000.00817.01
7.4.230.0070.00016.90
7.4.220.0100.01016.93
7.4.210.0070.00817.04
7.4.200.0000.00817.05
7.4.190.0070.00016.92
7.4.160.0130.00316.83
7.4.150.0070.01017.40
7.4.140.0130.00717.86
7.4.130.0080.01016.91
7.4.120.0120.00917.01
7.4.110.0120.00616.98
7.4.100.0120.00917.09
7.4.90.0070.01116.96
7.4.80.0070.01019.39
7.4.70.0060.01216.97
7.4.60.0070.01016.70
7.4.50.0030.00616.71
7.4.40.0090.00922.52
7.4.30.0070.01017.02
7.4.10.0070.01115.12
7.4.00.0100.00815.14
7.3.330.0000.00513.80
7.3.320.0000.00613.81
7.3.310.0050.00216.87
7.3.300.0030.00316.81
7.3.290.0100.01016.81
7.3.280.0080.01116.79
7.3.270.0060.01217.40
7.3.260.0110.01118.24
7.3.250.0090.01116.85
7.3.240.0090.00917.21
7.3.230.0090.00917.14
7.3.210.0090.00916.82
7.3.200.0130.01019.39
7.3.190.0200.00316.92
7.3.180.0120.00616.88
7.3.170.0070.01516.94
7.3.160.0130.00316.94
7.3.130.0000.01515.28
7.3.120.0050.01115.22
7.3.110.0060.01315.04
7.3.100.0130.00015.02
7.3.90.0070.00715.07
7.3.80.0070.00315.13
7.3.70.0040.01215.16
7.3.60.0070.01315.00
7.3.50.0090.01014.97
7.3.40.0070.01114.94
7.3.30.0100.00314.97
7.3.20.0100.00316.82
7.3.10.0030.01017.03
7.3.00.0060.00916.87
7.2.330.0110.00717.06
7.2.320.0040.01316.84
7.2.310.0180.00717.13
7.2.300.0130.00417.12
7.2.290.0090.01017.20
7.2.260.0040.01515.16
7.2.250.0100.00615.39
7.2.240.0120.00015.64
7.2.230.0080.00815.41
7.2.220.0090.00615.51
7.2.210.0000.01115.44
7.2.200.0000.01415.44
7.2.190.0100.01015.50
7.2.180.0120.00615.59
7.2.170.0000.01715.36
7.2.160.0040.01115.24
7.2.150.0090.00617.22
7.2.140.0100.00717.11
7.2.130.0030.01017.07
7.2.120.0060.00917.33
7.2.110.0070.01417.22
7.2.100.0100.00016.98
7.2.90.0040.01117.30
7.2.80.0150.00317.05
7.2.70.0070.00717.18
7.2.60.0050.01017.07
7.2.50.0040.01216.99
7.2.40.0000.01117.25
7.2.30.0000.01217.18
7.2.20.0090.00617.25
7.2.10.0080.00617.23
7.2.00.0080.00818.36
7.1.330.0040.01115.92
7.1.320.0090.00316.18
7.1.310.0090.00615.89
7.1.300.0090.00616.03
7.1.290.0100.00316.03
7.1.280.0070.01016.22
7.1.270.0130.00015.85
7.1.260.0060.00916.18
7.1.250.0070.00416.15
7.1.240.0160.00016.19
7.1.230.0120.00016.13
7.1.220.0030.00915.92
7.1.210.0090.00615.95
7.1.200.0120.00315.99
7.1.190.0060.00615.86
7.1.180.0050.00516.07
7.1.170.0000.01416.09
7.1.160.0070.00715.98
7.1.150.0040.01115.96
7.1.140.0060.00315.98
7.1.130.0060.00616.10
7.1.120.0000.01516.10
7.1.110.0050.00516.05
7.1.100.0100.00717.05
7.1.90.0000.01816.07
7.1.80.0060.00616.14
7.1.70.0060.00716.56
7.1.60.0110.01017.71
7.1.50.0080.00816.61
7.1.40.0030.01015.89
7.1.30.0000.01416.00
7.1.20.0040.01115.87
7.1.10.0030.00815.89
7.1.00.0020.04019.29
7.0.330.0000.00815.71
7.0.320.0000.00915.86
7.0.310.0060.00315.52
7.0.300.0000.01315.52
7.0.290.0030.01015.66
7.0.280.0000.01515.73
7.0.270.0110.00415.79
7.0.260.0040.00815.69
7.0.250.0070.00415.98
7.0.240.0070.01015.92
7.0.230.0000.01115.69
7.0.220.0000.01015.73
7.0.210.0030.00715.83
7.0.200.0030.00916.39
7.0.190.0070.00715.73
7.0.180.0090.00015.89
7.0.170.0060.00615.69
7.0.160.0140.00015.73
7.0.150.0040.01415.55
7.0.140.0020.04018.93
7.0.130.0030.00715.78
7.0.120.0000.01615.62
7.0.110.0040.00815.59
7.0.100.0060.00915.57
7.0.90.0100.00615.55
7.0.80.0130.00315.95
7.0.70.0030.04218.77
7.0.60.0100.04318.83
7.0.50.0040.04619.03
7.0.40.0000.03617.05
7.0.30.0070.03217.00
7.0.20.0070.03917.08
7.0.10.0050.03916.89
7.0.00.0050.04017.01
5.6.400.0070.01014.63
5.6.390.0090.01214.43
5.6.380.0120.00414.65
5.6.370.0040.01114.87
5.6.360.0040.01114.70
5.6.350.0110.00314.78
5.6.340.0060.00814.71
5.6.330.0060.00914.74
5.6.320.0060.00914.78
5.6.310.0040.01214.98
5.6.300.0070.01115.02
5.6.290.0090.00614.80
5.6.280.0090.03718.05
5.6.270.0030.01014.85
5.6.260.0030.01314.71
5.6.250.0060.00614.76
5.6.240.0090.00914.61
5.6.230.0060.00914.73
5.6.220.0020.04617.65
5.6.210.0030.04617.75
5.6.200.0070.04418.07
5.6.190.0020.03717.97
5.6.180.0110.03917.94
5.6.170.0080.03818.00
5.6.160.0070.04318.02
5.6.150.0070.04418.00
5.6.140.0030.04617.92
5.6.130.0040.04118.05
5.6.120.0030.04917.87
5.6.110.0060.04517.94
5.6.100.0070.03117.88
5.6.90.0090.03017.99
5.6.80.0050.04817.61
5.6.70.0070.04217.89
5.6.60.0070.03917.55
5.6.50.0070.04417.67
5.6.40.0030.04517.67
5.6.30.0110.03817.67
5.6.20.0020.04617.83
5.6.10.0080.04517.66
5.6.00.0020.03817.59
5.5.380.0090.00914.84
5.5.370.0040.01514.85
5.5.360.0030.04817.76
5.5.350.0100.02817.52
5.5.340.0050.02417.83
5.5.330.0050.03517.80
5.5.320.0050.03017.80
5.5.310.0100.04017.91
5.5.300.0080.04017.83
5.5.290.0080.04218.01
5.5.280.0020.04617.78
5.5.270.0060.03317.72
5.5.260.0070.03517.95
5.5.250.0050.04217.80
5.5.240.0060.04017.60
5.5.230.0080.03617.54
5.5.220.0090.03317.56
5.5.210.0020.03917.48
5.5.200.0080.03817.49
5.5.190.0070.04017.70
5.5.180.0030.03717.50
5.5.170.0090.00914.43
5.5.160.0050.04217.69
5.5.150.0030.03517.50
5.5.140.0040.03717.66
5.5.130.0050.03717.59
5.5.120.0050.02217.49
5.5.110.0060.03817.68
5.5.100.0030.02117.63
5.5.90.0050.02517.35
5.5.80.0090.01817.45
5.5.70.0050.02217.22
5.5.60.0070.01817.57
5.5.50.0030.02517.52
5.5.40.0020.02517.45
5.5.30.0050.02017.48
5.5.20.0050.02817.58
5.5.10.0030.02517.60
5.5.00.0040.02117.30
5.4.450.0060.03315.56
5.4.440.0050.04515.63
5.4.430.0070.02815.52
5.4.420.0030.03315.49
5.4.410.0030.04515.34
5.4.400.0030.04515.34
5.4.390.0050.03315.32
5.4.380.0080.02515.32
5.4.370.0050.03515.37
5.4.360.0030.04315.42
5.4.350.0040.04115.29
5.4.340.0050.02815.36
5.4.330.0090.00311.34
5.4.320.0060.03815.27
5.4.310.0050.03215.33
5.4.300.0050.03215.32
5.4.290.0020.02315.49
5.4.280.0070.04215.33
5.4.270.0020.04415.48
5.4.260.0030.02215.24
5.4.250.0080.03715.32
5.4.240.0020.02315.42
5.4.230.0020.02315.47
5.4.220.0030.03415.18
5.4.210.0030.02315.33
5.4.200.0080.01815.41
5.4.190.0030.02015.24
5.4.180.0030.01815.40
5.4.170.0050.02215.34
5.4.160.0000.03115.37
5.4.150.0030.02715.41
5.4.140.0020.02514.19
5.4.130.0040.01813.98
5.4.120.0040.03114.02
5.4.110.0000.03414.11
5.4.100.0030.02414.02
5.4.90.0060.01813.97
5.4.80.0020.02214.07
5.4.70.0030.03814.11
5.4.60.0020.02614.02
5.4.50.0020.02914.08
5.4.40.0030.02213.93
5.4.30.0000.02514.01
5.4.20.0030.02114.04
5.4.10.0030.02113.96
5.4.00.0030.03113.68
5.3.290.0030.03312.96
5.3.280.0020.04212.77
5.3.270.0030.01712.84
5.3.260.0050.01712.90
5.3.250.0080.02812.78
5.3.240.0020.02212.87
5.3.230.0000.02312.88
5.3.220.0000.02112.91
5.3.210.0040.03012.79
5.3.200.0040.02412.70
5.3.190.0000.02212.76
5.3.180.0020.02512.96
5.3.170.0050.02712.86
5.3.160.0030.03212.88
5.3.150.0050.02212.88
5.3.140.0000.02412.78
5.3.130.0050.02012.81
5.3.120.0020.02512.80
5.3.110.0080.01812.83
5.3.100.0050.02012.65
5.3.90.0050.02012.65
5.3.80.0040.01912.47
5.3.70.0050.02012.44
5.3.60.0020.02012.61
5.3.50.0020.02012.60
5.3.40.0020.02212.47
5.3.30.0050.01812.51
5.3.20.0050.02012.38
5.3.10.0040.01912.21
5.3.00.0020.02112.24
5.2.170.0000.03012.22
5.2.160.0030.02712.22
5.2.150.0030.02712.22
5.2.140.0000.03012.22
5.2.130.0000.03012.22
5.2.120.0000.03012.22
5.2.110.0000.03012.22
5.2.100.0030.02712.22
5.2.90.0030.02712.22
5.2.80.0030.02712.22
5.2.70.0000.03012.22
5.2.60.0070.02312.22
5.2.50.0030.02712.22
5.2.40.0000.03012.22
5.2.30.0030.02712.22
5.2.20.0030.03012.22
5.2.10.0070.02312.22
5.2.00.0030.03712.22
5.1.60.0030.05712.22
5.1.50.0000.05712.22
5.1.40.0030.05312.22
5.1.30.0030.05712.22
5.1.20.0030.05712.22
5.1.10.0000.06012.22
5.1.00.0000.06012.22
5.0.50.0070.02712.22
5.0.40.0000.04712.22
5.0.30.0030.05312.22
5.0.20.0000.04012.22
5.0.10.0030.04012.22
5.0.00.0070.05012.22
4.4.90.0000.01312.22
4.4.80.0000.02012.22
4.4.70.0000.01712.22
4.4.60.0000.01312.22
4.4.50.0000.01712.22
4.4.40.0000.05712.22
4.4.30.0000.03012.22
4.4.20.0030.03312.22
4.4.10.0000.03312.22
4.4.00.0000.04712.22
4.3.110.0000.03712.22
4.3.100.0030.02712.22
4.3.90.0070.03012.22
4.3.80.0000.04712.22
4.3.70.0070.03012.22
4.3.60.0030.03012.22
4.3.50.0030.03712.22
4.3.40.0030.05012.22
4.3.30.0030.03012.22
4.3.20.0000.02712.22
4.3.10.0030.03312.22
4.3.00.0030.03312.22

preferences:
47.54 ms | 401 KiB | 5 Q