3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.120.0000.01616.62
7.2.110.0080.00816.82
7.2.100.0090.00616.85
7.2.90.0110.00416.84
7.2.80.0070.00716.66
7.2.70.0110.00316.67
7.2.60.0030.00817.01
7.2.50.0120.00317.14
7.2.40.0030.01117.12
7.2.30.0070.01117.21
7.2.20.0070.00717.12
7.2.10.0030.00716.91
7.2.00.0070.00718.36
7.1.240.0060.00915.77
7.1.230.0060.00915.84
7.1.220.0090.00015.98
7.1.210.0100.00015.90
7.1.200.0040.01015.84
7.1.190.0030.01415.78
7.1.180.0030.01216.09
7.1.170.0000.01516.04
7.1.160.0030.00615.83
7.1.150.0070.00416.00
7.1.140.0070.00715.75
7.1.130.0060.00616.04
7.1.120.0030.01115.92
7.1.110.0040.01115.98
7.1.100.0000.01415.73
7.1.90.0030.00716.06
7.1.80.0030.01316.05
7.1.70.0090.00616.75
7.1.60.0060.00816.49
7.1.50.0070.01016.52
7.1.40.0070.00315.89
7.1.30.0080.00315.93
7.1.20.0060.00615.75
7.1.10.0070.00315.61
7.1.00.0040.04219.26
7.0.320.0120.00015.41
7.0.310.0070.00415.63
7.0.300.0100.00015.45
7.0.290.0070.00715.82
7.0.280.0100.00315.55
7.0.270.0030.01015.46
7.0.260.0040.00715.50
7.0.250.0060.00615.66
7.0.240.0040.01115.55
7.0.230.0040.00815.51
7.0.220.0000.01615.66
7.0.210.0070.00715.65
7.0.200.0030.01016.18
7.0.190.0060.00615.49
7.0.180.0000.01515.56
7.0.170.0000.01415.60
7.0.160.0040.00715.46
7.0.150.0070.00415.51
7.0.140.0060.03818.83
7.0.130.0000.00815.52
7.0.120.0070.00415.82
7.0.110.0030.00715.34
7.0.100.0080.04717.77
7.0.90.0230.03817.75
7.0.80.0070.02517.85
7.0.70.0040.02417.78
7.0.60.0060.02017.85
7.0.50.0080.04217.90
7.0.40.0030.02516.91
7.0.30.0060.02616.80
7.0.20.0100.04016.84
7.0.10.0030.04616.83
7.0.00.0110.04116.78
hhvm-3.22.00.0610.10291.84
hhvm-3.21.30.0510.11291.39
hhvm-3.21.00.0340.13491.88
hhvm-3.20.20.0570.11291.43
hhvm-3.19.20.0610.10690.90
hhvm-3.18.50.0630.10089.21
hhvm-3.18.40.0400.12189.83
hhvm-3.17.30.0500.09788.81
hhvm-3.15.40.0470.09786.29
hhvm-3.13.20.0400.11297.60
hhvm-3.12.140.0400.11396.68
hhvm-3.11.10.0400.11188.72
hhvm-3.10.10.0530.09385.27
5.6.380.0100.00714.72
5.6.370.0150.00015.01
5.6.360.0100.00314.61
5.6.350.0120.00314.61
5.6.340.0040.01114.51
5.6.330.0100.00314.77
5.6.320.0140.00414.79
5.6.310.0000.01214.72
5.6.300.0040.00814.84
5.6.290.0060.00614.69
5.6.280.0030.04217.82
5.6.270.0030.01014.73
5.6.260.0040.01114.30
5.6.250.0030.04717.80
5.6.240.0100.03617.62
5.6.230.0080.04617.67
5.6.220.0030.03517.63
5.6.210.0050.02317.64
5.6.200.0070.02317.91
5.6.190.0060.02517.82
5.6.180.0030.02517.88
5.6.170.0070.02317.81
5.6.160.0080.04117.79
5.6.150.0030.02817.74
5.6.140.0090.03117.92
5.6.130.0020.03118.01
5.6.120.0020.02617.88
5.6.110.0070.02317.77
5.6.100.0020.02918.04
5.6.90.0020.02818.00
5.6.80.0050.02417.54
5.6.70.0070.02617.68
5.6.60.0020.02717.57
5.6.50.0030.02717.60
5.6.40.0050.03017.54
5.6.30.0080.01817.46
5.6.20.0050.02117.62
5.6.10.0070.02217.58
5.6.00.0080.02017.54
5.5.380.0050.04515.91
5.5.370.0070.02715.94
5.5.360.0040.02716.05
5.5.350.0050.03216.05
5.5.340.0050.02316.13
5.5.330.0030.02516.29
5.5.320.0060.04116.12
5.5.310.0020.04216.11
5.5.300.0040.02516.22
5.5.290.0060.02016.21
5.5.280.0070.02216.26
5.5.270.0090.02116.30
5.5.260.0080.02516.33
5.5.250.0020.02916.10
5.5.240.0030.02415.66
5.5.230.0070.02015.80
5.5.220.0040.02115.74
5.5.210.0020.02715.76
5.5.200.0050.02415.83
5.5.190.0020.02615.72
5.5.180.0050.02215.84
5.5.170.0000.01114.73
5.5.160.0090.01615.62
5.5.150.0030.02415.96
5.5.140.0030.02015.93
5.5.130.0050.01715.90
5.5.120.0040.02015.88
5.5.110.0070.03515.85
5.5.100.0110.03515.78
5.5.90.0070.03915.82
5.5.80.0060.02515.77
5.5.70.0030.04215.73
5.5.60.0030.02515.82
5.5.50.0030.02515.78
5.5.40.0020.04215.70
5.5.30.0030.03915.78
5.5.20.0030.04015.75
5.5.10.0040.02515.80
5.5.00.0050.02715.85
5.4.450.0090.02215.59
5.4.440.0030.02615.39
5.4.430.0090.01615.57
5.4.420.0070.01815.35
5.4.410.0060.02715.35
5.4.400.0030.02315.16
5.4.390.0030.03615.29
5.4.380.0030.02315.26
5.4.370.0040.02015.24
5.4.360.0050.02215.08
5.4.350.0000.03215.14
5.4.340.0050.02015.40
5.4.330.0060.00611.42
5.4.320.0030.03115.26
5.4.310.0020.02315.23
5.4.300.0030.02215.25
5.4.290.0080.01815.13
5.4.280.0050.02015.16
5.4.270.0070.02914.99
5.4.260.0080.03815.21
5.4.250.0110.03715.29
5.4.240.0120.03815.17
5.4.230.0050.02315.00
5.4.220.0030.02915.26
5.4.210.0040.02715.33
5.4.200.0010.03015.32
5.4.190.0070.04215.12
5.4.180.0030.03515.10
5.4.170.0100.03915.30
5.4.160.0070.02315.16
5.4.150.0080.02515.14
5.4.140.0080.03314.01
5.4.130.0050.02513.96
5.4.120.0090.02913.96
5.4.110.0070.01814.11
5.4.100.0020.04213.87
5.4.90.0040.04414.16
5.4.80.0030.02313.83
5.4.70.0020.03913.99
5.4.60.0050.03113.98
5.4.50.0050.02713.91
5.4.40.0090.02113.87
5.4.30.0050.03913.93
5.4.20.0100.01713.97
5.4.10.0050.03414.00
5.4.00.0020.02313.70
5.3.290.0050.02112.89
5.3.280.0060.04112.81
5.3.270.0090.02312.84
5.3.260.0060.03812.82
5.3.250.0080.03912.77
5.3.240.0110.03912.72
5.3.230.0070.03712.83
5.3.220.0090.03412.74
5.3.210.0010.03912.71
5.3.200.0050.03812.75
5.3.190.0080.04412.78
5.3.180.0120.03512.92
5.3.170.0080.03812.90
5.3.160.0070.02412.85
5.3.150.0110.03512.84
5.3.140.0070.03112.85
5.3.130.0040.02712.79
5.3.120.0090.03212.77
5.3.110.0060.03912.81
5.3.100.0070.03712.50
5.3.90.0060.03512.43
5.3.80.0050.03712.48
5.3.70.0050.03312.47
5.3.60.0080.03312.50
5.3.50.0090.02612.55
5.3.40.0110.02712.35
5.3.30.0040.03412.38
5.3.20.0050.02412.25
5.3.10.0070.03112.18
5.3.00.0100.02812.18
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