3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * SimpleXMLElement Introspection */ error_reporting(~0); $xml = '<document> <child a3="v3"> 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[1]->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.0170.00016.88
8.3.50.0110.00822.03
8.3.40.0160.00319.23
8.3.30.0120.00319.12
8.3.20.0030.00520.53
8.3.10.0060.00923.77
8.3.00.0100.01019.63
8.2.180.0100.01016.88
8.2.170.0150.00322.96
8.2.160.0040.01120.64
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0150.00326.16
8.2.120.0090.00022.42
8.2.110.0050.00522.41
8.2.100.0090.00317.97
8.2.90.0000.00819.42
8.2.80.0030.00518.18
8.2.70.0090.00018.00
8.2.60.0040.00418.29
8.2.50.0000.00818.07
8.2.40.0000.00818.53
8.2.30.0080.00018.34
8.2.20.0000.00818.01
8.2.10.0030.00718.34
8.2.00.0000.00917.94
8.1.280.0040.01125.92
8.1.270.0000.00922.29
8.1.260.0080.00026.35
8.1.250.0110.00728.09
8.1.240.0000.01022.67
8.1.230.0070.00422.88
8.1.220.0040.00418.01
8.1.210.0040.00418.77
8.1.200.0000.00917.50
8.1.190.0000.00917.91
8.1.180.0050.00318.10
8.1.170.0000.00818.98
8.1.160.0050.00322.27
8.1.150.0030.00618.84
8.1.140.0050.00317.69
8.1.130.0000.00818.14
8.1.120.0030.00517.68
8.1.110.0020.00517.74
8.1.100.0040.00417.64
8.1.90.0050.00217.68
8.1.80.0000.00817.76
8.1.70.0030.00317.69
8.1.60.0050.00317.87
8.1.50.0030.00617.84
8.1.40.0040.00417.86
8.1.30.0030.00617.71
8.1.20.0030.00617.80
8.1.10.0040.00417.86
8.1.00.0040.00417.65
8.0.300.0080.00018.77
8.0.290.0000.00717.43
8.0.280.0000.00718.68
8.0.270.0080.00017.41
8.0.260.0080.00017.23
8.0.250.0030.00317.25
8.0.240.0000.00817.29
8.0.230.0000.00717.16
8.0.220.0040.00417.29
8.0.210.0000.00717.24
8.0.200.0000.00717.33
8.0.190.0030.00517.31
8.0.180.0000.00817.09
8.0.170.0030.00617.33
8.0.160.0050.00317.28
8.0.150.0000.00817.04
8.0.140.0000.00717.20
8.0.130.0050.00313.71
8.0.120.0040.00417.08
8.0.110.0040.00417.23
8.0.100.0040.00417.25
8.0.90.0000.00817.26
8.0.80.0090.00617.23
8.0.70.0000.00717.14
8.0.60.0040.00417.18
8.0.50.0000.00717.19
8.0.30.0110.00917.33
8.0.20.0110.00817.46
8.0.10.0040.00417.24
8.0.00.0090.00917.01
7.4.330.0030.00315.28
7.4.320.0030.00316.69
7.4.300.0070.00016.82
7.4.290.0070.00016.90
7.4.280.0030.00516.73
7.4.270.0000.00716.84
7.4.260.0030.00616.79
7.4.250.0040.00416.74
7.4.240.0050.00216.72
7.4.230.0020.00516.68
7.4.220.0030.01616.77
7.4.210.0080.00716.94
7.4.200.0040.00416.75
7.4.190.0000.00816.94
7.4.160.0080.01116.86
7.4.150.0090.00917.40
7.4.140.0180.00017.86
7.4.130.0100.00816.84
7.4.120.0110.00616.82
7.4.110.0110.00716.96
7.4.100.0090.01616.82
7.4.90.0090.00916.82
7.4.80.0100.00719.39
7.4.70.0100.00716.95
7.4.60.0130.00316.70
7.4.50.0000.00816.80
7.4.40.0060.01022.77
7.4.30.0070.01016.70
7.4.00.0110.00715.16
7.3.330.0060.00013.63
7.3.320.0060.00013.64
7.3.310.0030.00516.71
7.3.300.0030.00316.53
7.3.290.0130.00716.63
7.3.280.0080.00816.64
7.3.270.0150.00317.40
7.3.260.0140.00416.61
7.3.250.0090.00916.65
7.3.240.0070.01016.84
7.3.230.0100.00716.67
7.3.210.0070.01016.94
7.3.200.0140.00419.39
7.3.190.0040.01516.68
7.3.180.0070.01016.64
7.3.170.0070.01016.57
7.3.160.0060.01016.68
7.3.120.0080.00414.84
7.3.10.0140.00416.71
7.3.00.0080.00516.54
7.2.330.0070.01016.97
7.2.320.0070.01616.79
7.2.310.0000.01617.08
7.2.300.0000.01616.80
7.2.290.0230.00017.06
7.2.130.0070.00716.86
7.2.120.0080.00816.98
7.2.110.0070.00716.87
7.2.100.0170.00716.11
7.2.90.0130.00716.89
7.2.80.0130.01016.39
7.2.70.0160.00616.44
7.2.60.0100.00916.48
7.2.50.0100.01016.77
7.2.40.0180.00816.86
7.2.30.0030.01116.36
7.2.20.0200.00916.62
7.2.10.0120.00816.90
7.2.00.0060.00818.26
7.1.250.0060.00815.36
7.1.200.0060.00616.10
7.1.100.0040.01118.18
7.1.70.0070.00717.41
7.1.60.0070.01719.33
7.1.50.0040.01817.12
7.1.00.0070.07322.54
7.0.200.0030.00717.05
7.0.140.0030.07322.12
7.0.60.0070.08319.95
7.0.50.0070.08718.10
7.0.40.0070.08020.22
7.0.30.0530.06720.28
7.0.20.0230.04020.33
7.0.10.0130.08020.20
7.0.00.0030.04320.17
5.6.280.0070.07021.04
5.6.210.0030.08720.78
5.6.200.0070.05318.27
5.6.190.0170.07720.79
5.6.180.1370.05020.81
5.6.170.0300.07020.55
5.6.160.0130.08020.68
5.6.150.0030.04018.26
5.6.140.0070.04318.35
5.6.130.0030.04718.29
5.6.120.0100.08021.25
5.6.110.0070.08721.24
5.6.100.0100.08321.15
5.6.90.0030.09321.08
5.6.80.0000.07720.57
5.6.70.4300.03720.44
5.5.350.0070.07020.55
5.5.340.0200.06718.19
5.5.330.0030.04720.56
5.5.320.0270.03720.43
5.5.310.0330.07720.59
5.5.300.0070.08318.13
5.5.290.0070.03718.18
5.5.280.0070.06021.07
5.5.270.0030.08320.90
5.5.260.0170.06720.93
5.5.250.0130.08320.86
5.5.240.0170.03020.46
5.4.450.1670.03019.70
5.4.440.1700.04019.54
5.4.430.1730.03719.37
5.4.420.1830.04319.63
5.4.410.1930.03019.50
5.4.400.1800.04719.33
5.4.390.2070.04719.14
5.4.380.2200.04719.09
5.4.370.1300.03719.07
5.4.360.0030.04719.34
5.4.350.0070.03319.18
5.4.340.0030.03719.09
5.4.320.1230.04019.30
5.4.310.1700.03719.22
5.4.300.1730.04019.32
5.4.290.1730.03719.17
5.4.280.1870.04019.41
5.4.270.1800.04019.05
5.4.260.1870.03719.04
5.4.250.1870.04019.32
5.4.240.1830.04019.21
5.4.230.1870.03719.23
5.4.220.2000.03319.13
5.4.210.1800.04019.32
5.4.200.1970.03719.39
5.4.190.2300.04719.04
5.4.180.1830.04319.29
5.4.170.2330.04319.14
5.4.160.2130.04719.34
5.4.150.1400.03719.29
5.4.140.2030.03316.59
5.4.130.2270.04016.50
5.4.120.2270.03316.48
5.4.110.1970.03716.50
5.4.100.1930.03316.52
5.4.90.2270.04316.41
5.4.80.1900.03716.63
5.4.70.2400.03716.47
5.4.60.2070.03716.67
5.4.50.2200.03316.48
5.4.40.2070.04316.48
5.4.30.2270.04716.66
5.4.20.2270.04016.70
5.4.10.2270.04316.52
5.4.00.2300.04316.23
5.3.290.2100.04314.82
5.3.280.2100.04314.80
5.3.270.2000.04714.88
5.3.260.0000.06014.81
5.3.250.0070.06714.73
5.3.240.0070.06314.72
5.3.230.1030.06314.80
5.3.220.1800.03714.92
5.3.210.1930.04714.92
5.3.200.2500.03014.88
5.3.190.1930.03714.81
5.3.180.1800.04014.81
5.3.170.2230.03014.84
5.3.160.1900.04314.66
5.3.150.1930.04014.67
5.3.140.1900.03314.68
5.3.130.2170.05714.92
5.3.120.2070.04014.64
5.3.110.2030.04314.66
5.3.100.2070.04314.39
5.3.90.2030.04314.27
5.3.80.2100.04314.11
5.3.70.1970.04014.29
5.3.60.1970.03714.14
5.3.50.2070.04314.07
5.3.40.1930.03314.04
5.3.30.1970.04314.04
5.3.20.2130.04013.84
5.3.10.2170.03014.01
5.3.00.2100.03313.89
5.2.170.1530.03311.29
5.2.160.1870.03311.23
5.2.150.1770.03711.25
5.2.140.1530.02711.27
5.2.130.1770.02711.20
5.2.120.1730.03011.20
5.2.110.1730.03011.41
5.2.100.1530.02711.38
5.2.90.1470.03311.13
5.2.80.1930.04011.20
5.2.70.1800.03011.37
5.2.60.1830.03311.31
5.2.50.1670.03011.12
5.2.40.1300.02311.12
5.2.30.1470.03711.07
5.2.20.1330.03011.09
5.2.10.1600.02710.95
5.2.00.1630.02310.93
5.1.60.1200.02710.10
5.1.50.1670.02710.07
5.1.40.1330.01710.25
5.1.30.1200.03010.59
5.1.20.1230.02710.61
5.1.10.1400.02710.28
5.1.00.1530.02310.17
5.0.50.0770.0238.57
5.0.40.0670.0208.41
5.0.30.0600.0338.22
5.0.20.0800.0308.46
5.0.10.0630.0238.35
5.0.00.0670.0308.26
4.4.90.0870.0208.07
4.4.80.0700.0238.07
4.4.70.0700.0208.07
4.4.60.0730.0208.07
4.4.50.0800.0208.07
4.4.40.0770.0378.07
4.4.30.0670.0138.07
4.4.20.0630.0138.07
4.4.10.0630.0178.07
4.4.00.0630.0238.07
4.3.110.0630.0208.07
4.3.100.0600.0178.07
4.3.90.0630.0138.07
4.3.80.0730.0308.07
4.3.70.0630.0138.07
4.3.60.0700.0138.07
4.3.50.0670.0178.07
4.3.40.0770.0278.07
4.3.30.0330.0178.07
4.3.20.0470.0138.07
4.3.10.0330.0138.07
4.3.00.0400.0108.07

preferences:
44.27 ms | 401 KiB | 5 Q