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 mixed */ function simplexml_get_documentelement(SimpleXMLElement $element) { foreach($element as $element) break; list($documentElement) = $element->xpath('/*'); return $documentElement; } $documentElement = $simple; $attributeList = $simple->child->grandchild->attributes(); $attributeListEmpty = $simple->child->attributes(); $attribute = $simple->child->grandchild['a1']; $suite = array( 'get_documentelement' => array('simplexml_get_documentelement', array( array($documentElement, $documentElement), array($documentElement, $documentElement->child), array($documentElement, $documentElement->single), array($documentElement, $simple->xpath('/*')[0]), array($documentElement, $simple->simple->xpath('/*')[0]), array($documentElement, $documentElement->child[0]), array($documentElement, $documentElement->child->grandchild), array($documentElement, $attribute), array($documentElement, $attributeList), array(NULL, $attributeListEmpty), )), ); 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.0030.01717.38
8.3.50.0110.00522.22
8.3.40.0120.00319.27
8.3.30.0070.00719.67
8.3.20.0080.00020.70
8.3.10.0040.00423.90
8.3.00.0090.00021.28
8.2.180.0160.00317.13
8.2.170.0110.01122.96
8.2.160.0060.00920.81
8.2.150.0080.00024.18
8.2.140.0060.01524.66
8.2.130.0040.00426.16
8.2.120.0050.00321.27
8.2.110.0090.00022.66
8.2.100.0100.00319.61
8.2.90.0000.00919.84
8.2.80.0060.00318.13
8.2.70.0040.00818.13
8.2.60.0030.00618.43
8.2.50.0000.01018.11
8.2.40.0050.00320.51
8.2.30.0000.00718.77
8.2.20.0040.00420.00
8.2.10.0000.00818.60
8.2.00.0060.00318.22
8.1.280.0110.00425.92
8.1.270.0040.00424.21
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0030.00624.23
8.1.230.0120.00019.66
8.1.220.0060.00318.29
8.1.210.0060.00318.77
8.1.200.0000.01117.85
8.1.190.0000.00817.88
8.1.180.0080.00018.10
8.1.170.0040.00418.99
8.1.160.0000.00822.57
8.1.150.0050.00319.13
8.1.140.0000.00918.00
8.1.130.0030.00518.23
8.1.120.0030.00618.00
8.1.110.0080.00017.88
8.1.100.0070.00018.10
8.1.90.0070.00018.06
8.1.80.0040.00418.07
8.1.70.0000.00718.05
8.1.60.0040.00417.99
8.1.50.0040.00418.04
8.1.40.0000.00817.89
8.1.30.0000.00918.00
8.1.20.0000.00918.06
8.1.10.0060.00318.16
8.1.00.0000.01117.93
8.0.300.0040.00418.77
8.0.290.0050.00317.25
8.0.280.0050.00218.89
8.0.270.0040.00417.70
8.0.260.0070.00017.68
8.0.250.0000.00817.50
8.0.240.0050.00317.56
8.0.230.0040.00417.34
8.0.220.0000.00717.52
8.0.210.0040.00417.30
8.0.200.0040.00417.44
8.0.190.0040.00417.56
8.0.180.0070.00017.34
8.0.170.0030.00617.55
8.0.160.0040.00417.27
8.0.150.0080.00017.54
8.0.140.0040.00417.37
8.0.130.0000.00613.81
8.0.120.0080.00017.28
8.0.110.0000.00817.54
8.0.100.0040.00417.42
8.0.90.0040.00417.36
8.0.80.0040.01217.42
8.0.70.0000.00817.27
8.0.60.0040.00417.39
8.0.50.0000.00817.34
8.0.30.0110.00917.56
8.0.20.0140.00617.65
8.0.10.0030.00517.53
8.0.00.0080.01017.33
7.4.330.0030.00315.68
7.4.320.0060.00017.16
7.4.300.0030.00317.10
7.4.290.0040.00417.11
7.4.280.0080.00017.04
7.4.270.0040.00417.21
7.4.260.0030.00516.94
7.4.250.0040.00416.95
7.4.240.0060.00217.12
7.4.230.0040.00417.21
7.4.220.0070.01117.10
7.4.210.0120.00317.16
7.4.200.0000.00717.26
7.4.160.0130.00717.01
7.4.150.0140.00417.40
7.4.140.0110.01017.86
7.4.130.0120.00617.18
7.4.120.0100.00717.23
7.4.110.0070.01017.11
7.4.100.0060.01217.13
7.4.90.0050.01417.01
7.4.80.0080.01419.39
7.4.70.0180.00017.07
7.4.60.0070.01017.03
7.4.50.0000.00617.00
7.4.40.0100.00717.22
7.4.30.0090.01116.91
7.4.10.0070.01015.31
7.4.00.0070.00915.36
7.3.330.0030.00313.91
7.3.320.0050.00313.89
7.3.310.0000.00817.00
7.3.300.0030.00316.93
7.3.290.0050.01416.93
7.3.280.0070.01116.92
7.3.270.0130.00617.40
7.3.260.0120.00617.29
7.3.250.0170.00617.06
7.3.240.0140.00317.15
7.3.230.0210.00617.08
7.3.210.0180.00416.82
7.3.200.0160.00719.39
7.3.190.0140.00317.11
7.3.180.0090.01017.28
7.3.170.0170.00717.20
7.3.160.0070.01017.05
7.3.130.0130.00715.19
7.3.120.0080.00915.05
7.3.110.0080.00915.06
7.3.100.0030.01115.04
7.3.90.0050.00815.06
7.3.80.0090.00315.24
7.3.70.0080.00614.98
7.3.60.0050.00915.08
7.3.50.0030.01015.11
7.3.40.0070.00515.11
7.3.30.0060.00614.95
7.3.20.0050.00917.00
7.3.10.0030.01116.84
7.3.00.0040.00916.88
7.2.330.0090.00917.02
7.2.320.0100.00917.32
7.2.310.0070.01117.17
7.2.300.0120.00617.43
7.2.290.0140.01017.35
7.2.260.0030.01615.20
7.2.250.0080.01115.32
7.2.240.0070.00915.24
7.2.230.0080.00715.41
7.2.220.0080.00815.40
7.2.210.0040.01215.52
7.2.200.0060.01015.49
7.2.190.0050.01315.46
7.2.180.0060.01015.42
7.2.170.0030.00815.33
7.2.160.0060.00915.23
7.2.150.0070.00717.05
7.2.140.0060.00616.96
7.2.130.0060.00817.30
7.2.120.0030.01117.07
7.2.110.0050.00817.04
7.2.100.0070.00617.11
7.2.90.0020.00817.15
7.2.80.0030.01017.25
7.2.70.0070.00917.15
7.2.60.0090.00417.34
7.2.50.0090.00117.26
7.2.40.0030.00817.15
7.2.30.0110.00417.23
7.2.20.0100.00617.18
7.2.10.0060.00917.12
7.2.00.0040.00918.01
7.1.330.0030.01215.97
7.1.320.0070.00716.04
7.1.310.0020.01116.09
7.1.300.0050.00816.05
7.1.290.0060.00915.87
7.1.280.0050.00915.95
7.1.270.0080.00816.06
7.1.260.0020.01016.07
7.1.250.0040.00615.93
7.1.240.0050.00815.83
7.1.230.0030.01115.96
7.1.220.0060.00515.90
7.1.210.0070.00516.06
7.1.200.0090.00416.01
7.1.190.0050.00816.01
7.1.180.0070.00815.92
7.1.170.0020.00916.10
7.1.160.0070.00916.15
7.1.150.0060.00916.25
7.1.140.0110.00316.11
7.1.130.0050.00915.95
7.1.120.0030.01015.93
7.1.110.0030.01016.05
7.1.100.0110.00516.84
7.1.90.0130.00416.19
7.1.80.0070.01016.12
7.1.70.0060.00816.40
7.1.60.0100.00917.27
7.1.50.0100.01016.38
7.1.40.0090.00616.05
7.1.30.0070.00816.05
7.1.20.0060.00816.33
7.1.10.0090.00916.11
7.1.00.0050.03318.23
7.0.330.0060.00615.55
7.0.320.0030.01015.73
7.0.310.0050.00915.60
7.0.300.0070.00815.62
7.0.290.0090.00315.53
7.0.280.0070.00515.65
7.0.270.0030.00915.59
7.0.260.0050.01015.83
7.0.250.0050.00915.62
7.0.240.0030.01215.50
7.0.230.0060.01015.78
7.0.220.0090.00515.68
7.0.210.0090.00715.75
7.0.200.0050.00716.07
7.0.190.0050.00915.74
7.0.180.0090.00815.74
7.0.170.0080.00815.71
7.0.160.0100.00515.68
7.0.150.0080.00515.93
7.0.140.0070.03017.90
7.0.130.0070.00615.71
7.0.120.0060.00715.65
7.0.110.0090.00515.65
7.0.100.0060.00615.59
7.0.90.0090.00515.69
7.0.80.0080.00515.75
7.0.70.0080.03217.83
7.0.60.0060.03417.87
7.0.50.0030.03417.95
7.0.40.0070.03216.01
7.0.30.0040.03215.95
7.0.20.0100.03016.09
7.0.10.0000.03715.95
7.0.00.0060.03115.99
5.6.400.0030.00914.63
5.6.390.0070.00414.79
5.6.380.0050.00614.74
5.6.370.0050.00714.73
5.6.360.0030.01114.55
5.6.350.0070.00914.84
5.6.340.0080.00614.65
5.6.330.0080.00814.69
5.6.320.0030.01114.70
5.6.310.0030.00914.81
5.6.300.0070.00614.79
5.6.290.0080.00614.79
5.6.280.0060.03017.00
5.6.270.0030.01114.75
5.6.260.0100.00714.80
5.6.250.0090.00314.77
5.6.240.0090.00314.93
5.6.230.0070.00514.84
5.6.220.0070.02016.97
5.6.210.0080.02016.72
5.6.200.0050.03116.90
5.6.190.0130.03116.90
5.6.180.0040.03617.00
5.6.170.0030.02816.94
5.6.160.0030.03216.87
5.6.150.0030.03516.96
5.6.140.0030.02716.95
5.6.130.0080.02017.06
5.6.120.0050.02916.93
5.6.110.0040.03116.92
5.6.100.0060.02616.96
5.6.90.0040.03116.92
5.6.80.0050.02516.65
5.6.70.0070.03316.71
5.6.60.0090.03216.70
5.6.50.0080.03216.58
5.6.40.0070.03016.60
5.6.30.0050.03116.69
5.6.20.0070.03516.64
5.6.10.0050.03116.68
5.6.00.0070.02016.69
5.5.380.0060.00713.13
5.5.370.0030.00813.13
5.5.360.0020.03415.52
5.5.350.0030.03215.59
5.5.340.0040.02415.68
5.5.330.0040.02515.76
5.5.320.0090.03115.83
5.5.310.0030.02815.91
5.5.300.0060.03115.86
5.5.290.0040.03515.79
5.5.280.0050.02815.77
5.5.270.0050.03215.89
5.5.260.0080.01815.91
5.5.250.0030.02915.70
5.5.240.0050.03215.47
5.5.230.0070.02515.56
5.5.220.0050.02715.56
5.5.210.0040.02415.51
5.5.200.0070.02915.49
5.5.190.0100.01815.52
5.5.180.0070.03015.42
5.5.170.0020.01113.03
5.5.160.0050.02415.57
5.5.150.0060.02415.35
5.5.140.0020.03315.60
5.5.130.0050.02615.38
5.5.120.0100.02515.55
5.5.110.0030.03515.60
5.5.100.0030.03415.63
5.5.90.0030.02315.49
5.5.80.0050.02915.55
5.5.70.0090.02015.55
5.5.60.0040.03215.44
5.5.50.0070.03015.46
5.5.40.0060.01615.35
5.5.30.0050.03015.51
5.5.20.0090.02915.56
5.5.10.0060.03215.49
5.5.00.0070.02915.57
5.4.450.0040.02914.30
5.4.440.0030.02914.32
5.4.430.0040.03014.34
5.4.420.0040.02914.27
5.4.410.0050.02514.37
5.4.400.0060.01514.12
5.4.390.0030.03414.21
5.4.380.0050.03014.21
5.4.370.0060.02914.22
5.4.360.0050.03014.16
5.4.350.0000.03614.25
5.4.340.0020.03114.23
5.4.330.0040.00811.68
5.4.320.0050.02814.19
5.4.310.0010.03214.10
5.4.300.0060.02814.17
5.4.290.0040.02814.14
5.4.280.0040.02914.22
5.4.270.0030.03114.20
5.4.260.0020.03014.10
5.4.250.0000.03114.17
5.4.240.0020.03114.17
5.4.230.0030.03014.10
5.4.220.0050.02214.17
5.4.210.0060.01614.22
5.4.200.0060.02914.30
5.4.190.0030.02914.17
5.4.180.0050.02514.04
5.4.170.0020.02914.13
5.4.160.0060.02814.11
5.4.150.0030.02414.12
5.4.140.0010.02713.24
5.4.130.0050.02913.33
5.4.120.0040.02713.33
5.4.110.0020.03013.36
5.4.100.0030.03013.29
5.4.90.0060.02613.23
5.4.80.0070.02613.32
5.4.70.0030.02113.34
5.4.60.0040.02313.25
5.4.50.0030.02013.25
5.4.40.0080.02413.30
5.4.30.0020.02913.36
5.4.20.0030.03013.26
5.4.10.0050.02713.28
5.4.00.0040.02213.05
5.3.290.0060.02912.25
5.3.280.0040.02812.17
5.3.270.0020.03112.14
5.3.260.0050.02112.20
5.3.250.0070.02412.16
5.3.240.0040.03212.13
5.3.230.0020.03112.22
5.3.220.0050.02112.20
5.3.210.0030.02812.20
5.3.200.0040.02412.23
5.3.190.0030.02112.27
5.3.180.0050.02712.23
5.3.170.0020.03112.21
5.3.160.0030.02512.29
5.3.150.0010.02112.24
5.3.140.0050.02712.16
5.3.130.0010.02412.23
5.3.120.0030.03412.22
5.3.110.0050.03112.22
5.3.100.0050.02812.10
5.3.90.0060.02112.06
5.3.80.0050.02911.90
5.3.70.0030.02011.98
5.3.60.0050.02811.98
5.3.50.0040.02612.01
5.3.40.0050.01812.03
5.3.30.0040.02311.99
5.3.20.0060.01311.86
5.3.10.0040.02711.80
5.3.00.0020.03011.77
5.2.170.0050.02811.38
5.2.160.0050.03111.38
5.2.150.0030.03211.38
5.2.140.0000.02911.38
5.2.130.0000.03511.38
5.2.120.0060.02811.38
5.2.110.0020.02711.38
5.2.100.0050.03011.38
5.2.90.0020.02111.38
5.2.80.0020.03311.38
5.2.70.0100.02811.38
5.2.60.0030.03111.38
5.2.50.0050.02811.38
5.2.40.0030.02511.38
5.2.30.0050.03211.38
5.2.20.0060.02811.38
5.2.10.0050.02811.38
5.2.00.0040.02311.38
5.1.60.0030.01811.38
5.1.50.0070.01811.38
5.1.40.0040.02211.38
5.1.30.0040.02511.38
5.1.20.0020.02011.38
5.1.10.0060.02211.38
5.1.00.0060.02511.38
5.0.50.0000.02311.38
5.0.40.0020.02511.38
5.0.30.0010.03511.38
5.0.20.0050.01711.38
5.0.10.0050.02111.38
5.0.00.0000.03411.38
4.4.90.0030.01811.38
4.4.80.0000.02011.38
4.4.70.0000.01211.38
4.4.60.0080.01511.38
4.4.50.0030.01811.38
4.4.40.0020.01511.38
4.4.30.0000.02111.38
4.4.20.0030.01911.38
4.4.10.0030.01611.38
4.4.00.0050.02611.38
4.3.110.0050.01211.38
4.3.100.0020.01911.38
4.3.90.0030.01511.38
4.3.80.0020.02711.38
4.3.70.0000.01411.38
4.3.60.0030.01711.38
4.3.50.0010.01111.38
4.3.40.0010.03011.38
4.3.30.0000.02111.38
4.3.20.0000.02011.38
4.3.10.0070.01511.38
4.3.00.0010.01811.38

preferences:
49.61 ms | 401 KiB | 5 Q