3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xpath = "/x:bids_offers/x:market_submit/x:sem_gen_technical_offer/x:block_deloading/x:point"; $xml = new EformDOMDocument("1.0", "UTF-8"); //$root = $xml->createElement("bids_offers"); //$xml->appendChild($root); //$root->appendChild($xml->createElement("market_submit")); //$xml->formatOutput = true; //echo $xml->saveXML(); $str = <<<XML <?xml version="1.0" encoding="UTF-8"?> <bids_offers> <market_submit> <sem_gen_technical_offer> </sem_gen_technical_offer> </market_submit> </bids_offers> XML; $xml->loadXML($str); $rootNamespace = $xml->lookupNamespaceUri($xml->namespaceURI); $xml->xpath->registerNamespace('x', $rootNamespace); $xml->buildMissingTree($xpath); //$xml->formatOutput = true; $xml->formatOutput = true; echo $xml->saveXML(); class EformDOMDocument extends DOMDocument { public $xpath; public function __construct($version = null, $encoding = null) { parent::__construct($version, $encoding); $this->xpath = new DOMXPath($this); } public function setAttributeX($path, $attributeName, $attributeValue) { // check if path returns anything valid if ($this->xpath->query($path)->length == 0) { $this->buildMissingTree($path); } $this->xpath->query($path)->item(0)->setAttribute($attributeName, $attributeValue); } public function buildMissingTree($path) { $missingNodes = array(); $tempPath = $path; // build an array of missing elements in the path while ($this->xpath->query($tempPath)->length == 0) { $tempName = basename($tempPath); $tempPath = dirname($tempPath); // deal with such: testnode[@type='HOT'] or [#] if (strpos($tempName, '[') === FALSE) { // no attributes use $tempName $missingNodes[] = $this->createElement($tempName); } else { // split element name and attribute, create both separate, append attribute to element, push into the aray $tempHolder = explode('[', $tempName); $tempElement = $this->createElement($tempHolder[0]); // [1] is attribute, clean it up, split name and value if (strpos($tempHolder[1], '@') !== FALSE) { // element has attiribute if it has @ in the path piece $attParam = str_replace(array('@', '\'', ']'), '', $tempHolder[1]); $attribute = explode('=', $attParam); $tempElement->setAttribute($attribute[0], $attribute[1]); } // otherwise its a number of the node in the sequence, skip it, as if xml is generated is in order, //previous nodes should exist already $missingNodes[] = $tempElement; $tempElement = null; } } // build the structure with missing elements (use $missingNodes array) // get existing end //echo $tempPath; //var_dump($missingNodes[0]); $currentElement = $this->xpath->query($tempPath)->item(0); while (($newElement = array_pop($missingNodes)) !== NULL) { $currentElement->appendChild($newElement); $currentElement = $newElement; } } /** * Checks if document has at least one element with a name (and optional attribute) provided * * @param string $name * @return mixed */ public function hasElement($name, $attribute = '') { $elements = $this->getElementsByTagName($name); if ($elements->length > 0) { if ($attribute == '') { return true; } // if attribute provided, check through the list for the element with provided attribute for ($i = 0; $i < $elements->length; $i++) { // TODO fix that checks on attibute value too, not just name if ($elements->item($i)->hasAttribute($attribute)) { return $elements->item($i); //return true; } } } return false; } /** * * @param string $name * @param string $attributeParameters provided as "attr1name=value1;attr2name=value2...etc." * @return DOMElement */ public function createElementWithAttributes($name, $attributeParameters = '') { $element = $this->createElement($name); // atributes provided as "attr1name=value1;attr2name=value2...etc." if ($attributeParameters != '') { // separate multiple parameters $attributes = explode(';', $attributeParameters); // add parameters to the element foreach ($attributes as $attribute) { $keyvalue = explode('=', $attribute); $element->setAttribute($keyvalue[0], $keyvalue[1]); } } return $element; } }

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.0070.01419.18
8.3.50.0110.01222.08
8.3.40.0040.01419.18
8.3.30.0140.00019.21
8.3.20.0030.00619.13
8.3.10.0080.00021.47
8.3.00.0050.00323.86
8.2.180.0140.00717.25
8.2.170.0150.00622.96
8.2.160.0110.00320.85
8.2.150.0060.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00419.75
8.2.110.0060.00320.85
8.2.100.0110.00018.28
8.2.90.0030.00519.55
8.2.80.0000.00818.17
8.2.70.0050.00317.88
8.2.60.0090.00318.05
8.2.50.0040.00418.07
8.2.40.0080.00018.66
8.2.30.0080.00020.25
8.2.20.0040.00418.18
8.2.10.0000.00818.08
8.2.00.0060.00618.02
8.1.280.0110.00425.92
8.1.270.0080.00023.99
8.1.260.0150.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00022.84
8.1.230.0060.00621.35
8.1.220.0030.00618.77
8.1.210.0000.00919.39
8.1.200.0090.00017.72
8.1.190.0000.00917.89
8.1.180.0080.00018.10
8.1.170.0060.00319.15
8.1.160.0050.00219.32
8.1.150.0040.00418.99
8.1.140.0060.00317.72
8.1.130.0000.00718.14
8.1.120.0000.00717.95
8.1.110.0090.00017.84
8.1.100.0040.00417.95
8.1.90.0000.00717.71
8.1.80.0000.00717.98
8.1.70.0030.00317.80
8.1.60.0040.00417.91
8.1.50.0080.00017.80
8.1.40.0040.00417.92
8.1.30.0030.00617.89
8.1.20.0040.00418.07
8.1.10.0040.00417.90
8.1.00.0060.00617.88
8.0.300.0040.00420.35
8.0.290.0000.00717.41
8.0.280.0030.00618.75
8.0.270.0040.00417.58
8.0.260.0030.00617.25
8.0.250.0040.00417.42
8.0.240.0060.00317.42
8.0.230.0000.00817.22
8.0.220.0040.00417.20
8.0.210.0030.00317.20
8.0.200.0030.00317.42
8.0.190.0040.00417.31
8.0.180.0000.00817.45
8.0.170.0040.00417.38
8.0.160.0000.00817.41
8.0.150.0020.00517.27
8.0.140.0090.00317.26
8.0.130.0030.00313.74
8.0.120.0050.00615.58
8.0.110.0070.00415.50
8.0.100.0070.00415.47
8.0.90.0040.00615.57
8.0.80.0140.00115.53
8.0.70.0040.00615.62
8.0.60.0060.00515.57
8.0.50.0070.00415.59
8.0.30.0090.01016.36
8.0.20.0120.00616.28
8.0.10.0050.00315.63
8.0.00.0120.00316.09
7.4.330.0030.00315.04
7.4.320.0050.00517.00
7.4.300.0030.00316.93
7.4.290.0070.00017.12
7.4.280.0040.00416.94
7.4.270.0030.00516.93
7.4.260.0030.00313.65
7.4.250.0020.00615.31
7.4.240.0030.00415.36
7.4.230.0040.00415.40
7.4.220.0080.00715.30
7.4.210.0080.00716.33
7.4.200.0060.00215.22
7.4.190.0020.00715.29
7.4.180.0000.00613.77
7.4.160.0040.00815.43
7.4.150.0060.00715.55
7.4.140.0070.00716.45
7.4.130.0060.00915.93
7.4.120.0100.00715.80
7.4.110.0100.00615.23
7.4.100.0120.00315.38
7.4.90.0110.00215.26
7.4.80.0060.00716.49
7.4.70.0060.00715.24
7.4.60.0070.00915.41
7.4.50.0030.00615.13
7.4.40.0030.00817.91
7.4.30.0060.00915.28
7.4.20.0000.00713.56
7.4.10.0030.00313.61
7.4.00.0060.00514.41
7.3.330.0000.00513.86
7.3.320.0000.00613.71
7.3.310.0030.00515.37
7.3.300.0060.00115.28
7.3.290.0100.00515.34
7.3.280.0070.00716.06
7.3.270.0070.00815.60
7.3.260.0080.00616.67
7.3.250.0070.00815.97
7.3.240.0040.00815.30
7.3.230.0090.00315.39
7.3.220.0000.00813.78
7.3.210.0040.01215.23
7.3.200.0070.00416.46
7.3.190.0090.00415.37
7.3.180.0070.00515.26
7.3.170.0070.00615.36
7.3.160.0050.00715.36
7.3.150.0000.00713.74
7.3.140.0020.00513.52
7.3.130.0000.00613.74
7.3.120.0040.00714.36
7.3.110.0050.00213.52
7.3.100.0050.00513.42
7.3.90.0000.00813.79
7.3.80.0060.00013.62
7.3.70.0000.00513.50
7.3.60.0050.00013.77
7.3.50.0000.00613.90
7.3.40.0000.00613.55
7.3.30.0000.00613.59
7.3.20.0030.00315.47
7.3.10.0000.00715.55
7.3.00.0030.01016.11
7.2.340.0100.00313.87
7.2.330.0060.01115.33
7.2.320.0100.00615.51
7.2.310.0150.00315.45
7.2.300.0080.01015.29
7.2.290.0080.00815.30
7.2.280.0130.00013.87
7.2.270.0100.00513.75
7.2.260.0090.00413.61
7.2.250.0050.00713.88
7.2.240.0100.00513.62
7.2.230.0110.00513.89
7.2.220.0080.00513.79
7.2.210.0100.00513.83
7.2.200.0100.00514.07
7.2.190.0070.00714.02
7.2.180.0140.00014.02
7.2.170.0090.00514.06
7.2.160.0040.00813.80
7.2.150.0140.00015.79
7.2.140.0090.00515.65
7.2.130.0100.00616.34
7.2.120.0130.00416.49
7.2.110.0060.01116.49
7.2.100.0140.00116.38
7.2.90.0070.00816.40
7.2.80.0070.00916.25
7.2.70.0090.00816.42
7.2.60.0080.00816.59
7.2.50.0110.00316.35
7.2.40.0110.00516.61
7.2.30.0100.00616.26
7.2.20.0090.00616.45
7.2.10.0110.00516.44
7.2.00.0080.00617.45
7.1.330.0130.00014.72
7.1.320.0120.00014.55
7.1.310.0040.00814.54
7.1.300.0080.00514.71
7.1.290.0110.00314.58
7.1.280.0070.00714.65
7.1.270.0060.00614.52
7.1.260.0080.00414.66
7.1.250.0100.00415.15
7.1.240.0090.00215.49
7.1.230.0080.00615.23
7.1.220.0090.00615.20
7.1.210.0070.00515.18
7.1.200.0060.00715.59
7.1.190.0100.00515.44
7.1.180.0080.00815.41
7.1.170.0100.00415.46
7.1.160.0060.00815.28
7.1.150.0040.00915.26
7.1.140.0120.00215.32
7.1.130.0120.00215.22
7.1.120.0060.00715.21
7.1.110.0130.00215.43
7.1.100.0110.00416.27
7.1.90.0080.00815.30
7.1.80.0110.00315.28
7.1.70.0060.00615.92
7.1.60.0080.01016.61
7.1.50.0110.00815.93
7.1.40.0090.00715.35
7.1.30.0140.00315.29
7.1.20.0090.00415.34
7.1.10.0070.00715.25
7.1.00.0080.01417.71
7.0.330.0110.00514.87
7.0.320.0140.00515.25
7.0.310.0120.00715.13
7.0.300.0080.00815.23
7.0.290.0110.00815.05
7.0.280.0120.00515.11
7.0.270.0110.00615.18
7.0.260.0150.00315.15
7.0.250.0070.00915.05
7.0.240.0080.00715.04
7.0.230.0160.00014.98
7.0.220.0100.00615.15
7.0.210.0110.00415.09
7.0.200.0130.00315.74
7.0.190.0140.00815.15
7.0.180.0140.00615.06
7.0.170.0090.00715.17
7.0.160.0070.00715.05
7.0.150.0130.00814.96
7.0.140.0050.03317.45
7.0.130.0150.00415.13
7.0.120.0100.00815.03
7.0.110.0160.00615.06
7.0.100.0150.00315.00
7.0.90.0130.00614.99
7.0.80.0140.00515.12
7.0.70.0090.01917.36
7.0.60.0080.02017.38
7.0.50.0080.01917.53
7.0.40.0110.01616.16
7.0.30.0100.02016.17
7.0.20.0100.02416.00
7.0.10.0100.01516.20
7.0.00.0070.02216.09
5.6.400.0060.00613.00
5.6.390.0040.00813.37
5.6.380.0060.00813.87
5.6.370.0070.00713.68
5.6.360.0090.00513.88
5.6.350.0080.00513.94
5.6.340.0090.00414.00
5.6.330.0090.00314.06
5.6.320.0080.00514.07
5.6.310.0100.00413.97
5.6.300.0040.00713.86
5.6.290.0080.00413.99
5.6.280.0050.03016.26
5.6.270.0050.00814.03
5.6.260.0100.00713.69
5.6.250.0090.00713.79
5.6.240.0070.00913.81
5.6.230.0050.00813.95
5.6.220.0090.02316.12
5.6.210.0080.01716.14
5.6.200.0080.01716.49
5.6.190.0110.01516.43
5.6.180.0090.01316.39
5.6.170.0000.03316.37
5.6.160.0070.01716.41
5.6.150.0070.01616.24
5.6.140.0080.01616.56
5.6.130.0100.01616.28
5.6.120.0060.02716.40
5.6.110.0060.01916.32
5.6.100.0060.01916.42
5.6.90.0130.02516.22
5.6.80.0100.02016.20
5.6.70.0070.03216.21
5.6.60.0040.02516.21
5.6.50.0080.01616.08
5.6.40.0110.03016.08
5.6.30.0080.01716.09
5.6.20.0060.03416.13
5.6.10.0060.01816.14
5.6.00.0020.01716.13
5.5.380.0090.00512.45
5.5.370.0080.00312.49
5.5.360.0030.02115.11
5.5.350.0050.02115.21
5.5.340.0070.01615.23
5.5.330.0080.01515.35
5.5.320.0050.01815.30
5.5.310.0070.01915.20
5.5.300.0040.01615.29
5.5.290.0050.02615.16
5.5.280.0030.02015.15
5.5.270.0040.01815.22
5.5.260.0030.02215.22
5.5.250.0040.03015.14
5.5.240.0070.02815.06
5.5.230.0060.03114.96
5.5.220.0050.03114.99
5.5.210.0070.01915.01
5.5.200.0060.02114.92
5.5.190.0060.01715.02
5.5.180.0060.01615.04
5.5.170.0090.00412.36
5.5.160.0060.02914.97
5.5.150.0060.03114.89
5.5.140.0060.01914.89
5.5.130.0070.02814.88
5.5.120.0050.03215.13
5.5.110.0010.02815.05
5.5.100.0040.02915.04
5.5.90.0020.02714.95
5.5.80.0100.02414.99
5.5.70.0040.02914.96
5.5.60.0030.03415.00
5.5.50.0050.03015.14
5.5.40.0090.02815.11
5.5.30.0060.02914.92
5.5.20.0080.02814.87
5.5.10.0040.02914.83
5.5.00.0080.02514.81
5.4.450.0070.02714.65
5.4.440.0050.01514.82
5.4.430.0050.01814.52
5.4.420.0080.02414.63
5.4.410.0090.02914.66
5.4.400.0080.02814.57
5.4.390.0060.03114.48
5.4.380.0080.02814.45
5.4.370.0030.03014.43
5.4.360.0060.01514.56
5.4.350.0060.01814.46
5.4.340.0070.03114.52
5.4.330.0060.00312.26
5.4.320.0060.02914.67
5.4.310.0060.02914.59
5.4.300.0080.02714.41
5.4.290.0070.02914.47
5.4.280.0040.02414.65
5.4.270.0060.02914.56
5.4.260.0060.02314.56
5.4.250.0030.03014.44
5.4.240.0050.02814.41
5.4.230.0060.02914.35
5.4.220.0040.03014.44
5.4.210.0070.02814.43
5.4.200.0040.03114.46
5.4.190.0070.02614.34
5.4.180.0100.01914.39
5.4.170.0080.02514.46
5.4.160.0070.02414.42
5.4.150.0070.01314.49
5.4.140.0070.01313.61
5.4.130.0070.01213.66
5.4.120.0040.02013.72
5.4.110.0050.02813.76
5.4.100.0070.02913.63
5.4.90.0050.02613.70
5.4.80.0020.02313.63
5.4.70.0070.01913.68
5.4.60.0040.02213.81
5.4.50.0100.02213.78
5.4.40.0040.02313.59
5.4.30.0080.02413.61
5.4.20.0040.02313.79
5.4.10.0060.02613.61
5.4.00.0080.02513.47
5.3.290.0070.02513.17
5.3.280.0050.02813.02
5.3.270.0040.03113.04
5.3.260.0010.01813.11
5.3.250.0040.01613.12
5.3.240.0060.01512.94
5.3.230.0040.02913.01
5.3.220.0060.01513.10
5.3.210.0040.01612.92
5.3.200.0050.02613.08
5.3.190.0050.03112.99
5.3.180.0040.02913.11
5.3.170.0060.01913.08
5.3.160.0020.03413.09
5.3.150.0070.02413.17
5.3.140.0060.02913.17
5.3.130.0030.02913.11
5.3.120.0070.02713.19
5.3.110.0060.02613.20
5.3.100.0060.01612.93
5.3.90.0060.02712.82
5.3.80.0040.03112.86
5.3.70.0030.02912.89
5.3.60.0040.03012.78
5.3.50.0050.02912.87
5.3.40.0040.02612.82
5.3.30.0020.03012.75
5.3.20.0040.02812.81
5.3.10.0050.01712.67
5.3.00.0060.02712.52
5.2.170.0010.02711.34
5.2.160.0050.02311.34
5.2.150.0050.02111.39
5.2.140.0030.02511.39
5.2.130.0050.02211.31
5.2.120.0030.02011.32
5.2.110.0040.02111.27
5.2.100.0090.02011.26
5.2.90.0030.02411.25
5.2.80.0030.02411.32
5.2.70.0020.01911.25
5.2.60.0030.02411.34
5.2.50.0040.02211.35
5.2.40.0050.02311.34
5.2.30.0030.02311.20
5.2.20.0050.02311.16
5.2.10.0030.02311.10
5.2.00.0030.01911.01
5.1.60.0050.01810.79
5.1.50.0060.01710.79
5.1.40.0030.01410.99
5.1.30.0010.02110.96
5.1.20.0050.01810.84
5.1.10.0030.02110.81
5.1.00.0060.01710.94
5.0.50.0020.01810.63
5.0.40.0020.01610.56
5.0.30.0040.02510.56
5.0.20.0020.01910.57
5.0.10.0010.02010.56
5.0.00.0020.01610.56
4.4.90.0020.00910.56
4.4.80.0010.01210.56
4.4.70.0010.01110.56
4.4.60.0000.01510.56
4.4.50.0020.01310.56
4.4.40.0010.02010.56
4.4.30.0010.01410.56
4.4.20.0030.01110.56
4.4.10.0030.01310.56
4.4.00.0040.01910.56
4.3.110.0020.01310.56
4.3.100.0020.00910.56
4.3.90.0040.00910.56
4.3.80.0010.01710.56
4.3.70.0020.01410.56
4.3.60.0010.01510.56
4.3.50.0020.01110.56
4.3.40.0010.01910.56
4.3.30.0020.01410.56
4.3.20.0020.01410.56
4.3.10.0020.01310.56
4.3.00.0040.00910.56

preferences:
50.3 ms | 401 KiB | 5 Q