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"; $xpath = "//bids_offers/market_submit/sem_gen_technical_offer/block_deloading/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.70.0090.00617.13
8.3.60.0150.00617.13
8.3.50.0160.00422.24
8.3.40.0090.00619.21
8.3.30.0100.01019.54
8.3.20.0090.00020.56
8.3.10.0080.00024.03
8.3.00.0000.00819.63
8.2.180.0160.00318.91
8.2.170.0040.01122.96
8.2.160.0030.01020.89
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00422.52
8.2.110.0080.00322.63
8.2.100.0040.00818.22
8.2.90.0080.00019.72
8.2.80.0060.00318.18
8.2.70.0060.00317.88
8.2.60.0080.00018.15
8.2.50.0060.00318.07
8.2.40.0030.00618.59
8.2.30.0000.00718.55
8.2.20.0050.00318.25
8.2.10.0030.00518.48
8.2.00.0000.00918.20
8.1.280.0060.01225.92
8.1.270.0040.00424.04
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0060.00324.26
8.1.230.0040.00719.52
8.1.220.0000.00818.05
8.1.210.0030.00618.77
8.1.200.0040.00417.85
8.1.190.0000.00817.93
8.1.180.0030.00618.10
8.1.170.0000.00919.13
8.1.160.0040.00422.34
8.1.150.0080.00019.13
8.1.140.0000.01017.89
8.1.130.0040.00418.23
8.1.120.0000.00717.74
8.1.110.0000.00817.82
8.1.100.0040.00417.95
8.1.90.0080.00017.79
8.1.80.0030.00617.80
8.1.70.0000.00717.76
8.1.60.0030.00518.07
8.1.50.0080.00017.84
8.1.40.0040.00418.02
8.1.30.0030.00618.09
8.1.20.0040.00417.93
8.1.10.0020.00517.88
8.1.00.0080.00018.05
8.0.300.0000.00718.77
8.0.290.0050.00217.43
8.0.280.0070.00018.86
8.0.270.0070.00017.61
8.0.260.0040.00417.18
8.0.250.0000.00817.48
8.0.240.0080.00017.48
8.0.230.0070.00017.32
8.0.220.0040.00417.17
8.0.210.0030.00317.42
8.0.200.0070.00017.27
8.0.190.0000.00817.36
8.0.180.0050.00317.41
8.0.170.0040.00417.31
8.0.160.0070.00017.21
8.0.150.0040.00417.21
8.0.140.0040.00417.30
8.0.130.0060.00013.71
8.0.120.0030.00415.52
8.0.110.0000.00715.49
8.0.100.0020.00615.68
8.0.90.0020.00615.46
8.0.80.0060.00615.58
8.0.70.0040.00415.53
8.0.60.0030.00515.52
8.0.50.0030.00515.52
8.0.30.0090.00916.29
8.0.20.0110.00616.27
8.0.10.0050.00315.76
8.0.00.0090.00616.09
7.4.330.0050.00015.39
7.4.320.0030.00317.03
7.4.300.0040.00417.10
7.4.290.0000.00817.02
7.4.280.0040.00416.93
7.4.270.0000.00716.80
7.4.260.0030.00317.07
7.4.250.0050.00315.26
7.4.240.0040.00415.92
7.4.230.0060.00215.43
7.4.220.0060.00815.35
7.4.210.0070.00616.19
7.4.200.0060.00315.29
7.4.190.0060.00215.46
7.4.180.0040.00413.78
7.4.160.0030.00915.38
7.4.150.0040.00915.55
7.4.140.0090.00516.48
7.4.130.0040.01015.86
7.4.120.0080.00615.89
7.4.110.0140.00215.31
7.4.100.0080.00615.29
7.4.90.0060.00815.37
7.4.80.0080.00816.46
7.4.70.0060.00715.44
7.4.60.0090.00515.35
7.4.50.0050.00615.16
7.4.40.0080.00518.18
7.4.30.0080.00615.33
7.4.20.0060.00613.67
7.4.10.0100.00614.32
7.4.00.0040.00914.65
7.3.330.0060.00013.86
7.3.320.0000.00613.86
7.3.310.0070.00115.37
7.3.300.0050.00215.19
7.3.290.0080.00315.21
7.3.280.0070.00916.05
7.3.270.0080.00715.53
7.3.260.0080.00815.36
7.3.250.0050.01015.76
7.3.240.0120.00415.34
7.3.230.0090.00715.29
7.3.220.0110.00013.79
7.3.210.0050.00815.14
7.3.200.0110.00416.46
7.3.190.0130.00015.40
7.3.180.0060.00615.31
7.3.170.0070.00515.36
7.3.160.0070.00715.46
7.3.150.0020.00513.60
7.3.140.0000.00613.80
7.3.130.0030.01014.42
7.3.120.0070.00614.64
7.3.110.0050.00514.36
7.3.100.0030.00814.40
7.3.90.0050.00614.32
7.3.80.0010.01014.34
7.3.70.0020.01014.35
7.3.60.0030.00814.41
7.3.50.0040.00514.45
7.3.40.0050.00514.33
7.3.30.0030.00414.31
7.3.20.0030.00516.25
7.3.10.0060.00416.16
7.3.00.0030.00416.11
7.2.340.0070.00513.70
7.2.330.0140.00515.35
7.2.320.0080.01015.51
7.2.310.0120.00315.47
7.2.300.0100.00715.47
7.2.290.0070.00815.36
7.2.280.0120.00013.62
7.2.270.0120.00013.90
7.2.260.0110.00514.61
7.2.250.0090.00614.60
7.2.240.0070.00614.71
7.2.230.0110.00214.46
7.2.220.0110.00214.52
7.2.210.0090.00414.52
7.2.200.0080.00614.64
7.2.190.0060.00814.53
7.2.180.0080.00314.62
7.2.170.0050.00914.61
7.2.160.0060.00814.62
7.2.150.0050.00916.33
7.2.140.0060.00816.43
7.2.130.0050.00916.43
7.2.120.0050.00716.44
7.2.110.0100.00116.48
7.2.100.0080.00516.26
7.2.90.0060.00816.39
7.2.80.0050.00816.32
7.2.70.0100.00516.51
7.2.60.0080.00716.59
7.2.50.0070.00416.45
7.2.40.0080.00516.43
7.2.30.0060.00616.39
7.2.20.0080.00316.32
7.2.10.0080.00716.46
7.2.00.0050.01017.41
7.1.330.0110.00215.36
7.1.320.0060.00915.29
7.1.310.0070.00615.25
7.1.300.0110.00215.17
7.1.290.0040.00715.23
7.1.280.0060.00515.12
7.1.270.0110.00215.35
7.1.260.0080.00315.13
7.1.250.0080.00515.17
7.1.240.0050.00615.24
7.1.230.0060.00515.23
7.1.220.0040.00915.27
7.1.210.0090.00215.23
7.1.200.0070.00715.60
7.1.190.0050.00815.38
7.1.180.0060.00615.22
7.1.170.0080.00515.17
7.1.160.0080.00315.28
7.1.150.0020.01315.25
7.1.140.0020.01215.42
7.1.130.0060.00615.19
7.1.120.0060.00715.36
7.1.110.0080.00315.19
7.1.100.0050.00916.20
7.1.90.0080.00615.30
7.1.80.0070.00315.12
7.1.70.0040.00615.79
7.1.60.0100.00716.59
7.1.50.0040.00915.84
7.1.40.0050.00815.24
7.1.30.0060.00615.33
7.1.20.0110.00315.22
7.1.10.0030.00915.20
7.1.00.0050.02817.75
7.0.330.0030.00915.07
7.0.320.0000.01315.07
7.0.310.0100.00315.01
7.0.300.0050.00714.96
7.0.290.0060.00415.07
7.0.280.0060.00614.93
7.0.270.0080.00515.14
7.0.260.0090.00214.92
7.0.250.0060.00815.11
7.0.240.0090.00315.11
7.0.230.0090.00115.14
7.0.220.0120.00015.14
7.0.210.0080.00415.07
7.0.200.0070.00515.79
7.0.190.0030.01015.12
7.0.180.0080.00514.94
7.0.170.0050.00915.23
7.0.160.0080.00215.17
7.0.150.0050.00715.09
7.0.140.0050.02817.55
7.0.130.0080.00315.14
7.0.120.0090.00315.18
7.0.110.0070.01916.86
7.0.100.0080.02616.74
7.0.90.0120.01816.85
7.0.80.0110.02916.77
7.0.70.0080.02416.77
7.0.60.0090.03016.87
7.0.50.0100.02416.68
7.0.40.0070.03116.06
7.0.30.0060.03015.96
7.0.20.0100.02516.00
7.0.10.0090.02916.09
7.0.00.0020.03615.98
5.6.400.0040.00614.22
5.6.390.0080.00613.69
5.6.380.0110.00213.98
5.6.370.0080.00313.87
5.6.360.0060.00813.95
5.6.350.0050.00513.79
5.6.340.0020.01213.73
5.6.330.0050.00913.90
5.6.320.0070.00713.91
5.6.310.0050.00714.05
5.6.300.0050.00813.97
5.6.290.0080.00514.02
5.6.280.0050.02816.38
5.6.270.0090.00414.04
5.6.260.0060.03116.26
5.6.250.0080.02016.25
5.6.240.0070.02716.26
5.6.230.0070.03116.24
5.6.220.0140.02816.16
5.6.210.0070.03116.15
5.6.200.0060.02016.24
5.6.190.0080.03916.38
5.6.180.0090.03016.30
5.6.170.0070.03016.22
5.6.160.0090.02916.16
5.6.150.0070.03016.48
5.6.140.0060.03716.22
5.6.130.0070.03016.37
5.6.120.0100.02916.41
5.6.110.0080.03116.44
5.6.100.0080.03216.21
5.6.90.0050.03316.40
5.6.80.0050.03216.12
5.6.70.0060.03016.00
5.6.60.0040.03116.06
5.6.50.0070.02915.94
5.6.40.0130.02416.02
5.6.30.0090.02416.09
5.6.20.0050.02915.95
5.6.10.0130.02616.00
5.6.00.0130.02616.10
5.5.380.0060.02816.45
5.5.370.0100.02916.11
5.5.360.0060.03016.18
5.5.350.0080.02516.27
5.5.340.0070.03016.39
5.5.330.0060.02216.28
5.5.320.0100.03016.44
5.5.310.0070.03316.39
5.5.300.0130.02416.31
5.5.290.0100.02516.23
5.5.280.0110.02916.46
5.5.270.0090.02016.29
5.5.260.0120.02716.42
5.5.250.0100.03016.12
5.5.240.0090.02916.06
5.5.230.0090.02916.03
5.5.220.0090.02816.20
5.5.210.0050.02616.13
5.5.200.0020.03716.05
5.5.190.0110.02816.13
5.5.180.0110.02815.91
5.5.170.0120.00213.73
5.5.160.0110.02616.11
5.5.150.0130.02415.92
5.5.140.0060.03115.99
5.5.130.0130.02816.10
5.5.120.0110.02815.96
5.5.110.0070.01816.01
5.5.100.0090.03015.90
5.5.90.0080.01915.98
5.5.80.0100.02416.06
5.5.70.0070.03016.20
5.5.60.0070.03016.02
5.5.50.0070.02916.05
5.5.40.0090.03015.89
5.5.30.0050.01916.09
5.5.20.0090.02716.09
5.5.10.0090.01416.09
5.5.00.0090.02715.96
5.4.450.0040.03214.71
5.4.440.0050.03114.75
5.4.430.0050.03114.71
5.4.420.0120.02514.78
5.4.410.0140.02114.71
5.4.400.0100.02714.65
5.4.390.0090.02714.67
5.4.380.0080.03014.57
5.4.370.0090.02714.65
5.4.360.0050.03114.65
5.4.350.0080.02714.71
5.4.340.0120.02314.59
5.4.330.0060.00612.45
5.4.320.0110.02514.64
5.4.310.0070.03014.77
5.4.300.0050.02914.72
5.4.290.0070.03114.50
5.4.280.0070.02914.64
5.4.270.0080.02814.55
5.4.260.0050.03114.57
5.4.250.0060.03114.65
5.4.240.0090.02614.49
5.4.230.0030.03314.48
5.4.220.0070.02914.68
5.4.210.0070.02314.46
5.4.200.0030.03114.71
5.4.190.0070.02814.50
5.4.180.0060.02714.51
5.4.170.0070.02514.58
5.4.160.0090.01414.50
5.4.150.0090.02814.56
5.4.140.0080.02713.69
5.4.130.0040.02513.76
5.4.120.0060.02513.78
5.4.110.0050.02113.67
5.4.100.0080.02313.74
5.4.90.0140.01713.80
5.4.80.0100.02513.74
5.4.70.0050.02813.75
5.4.60.0060.02213.70
5.4.50.0100.01613.64
5.4.40.0090.02613.66
5.4.30.0070.02713.87
5.4.20.0050.01713.76
5.4.10.0100.02713.73
5.4.00.0060.02313.63
5.3.290.0050.02913.15
5.3.280.0060.03012.93
5.3.270.0050.03013.09
5.3.260.0070.02713.15
5.3.250.0040.03313.05
5.3.240.0070.02712.94
5.3.230.0060.02613.00
5.3.220.0070.02713.06
5.3.210.0050.02913.02
5.3.200.0070.02512.96
5.3.190.0070.02813.05
5.3.180.0050.03213.21
5.3.170.0060.01913.24
5.3.160.0050.02813.25
5.3.150.0050.03013.04
5.3.140.0050.03013.19
5.3.130.0050.02913.08
5.3.120.0050.02313.01
5.3.110.0080.02313.06
5.3.100.0090.02112.92
5.3.90.0030.02912.86
5.3.80.0050.02912.74
5.3.70.0060.02712.84
5.3.60.0030.02912.77
5.3.50.0100.02312.83
5.3.40.0070.02712.71
5.3.30.0100.02412.90
5.3.20.0050.01812.63
5.3.10.0050.02712.63
5.3.00.0070.02612.44
5.2.170.0000.03812.08
5.2.160.0070.02912.29
5.2.150.0080.03112.25
5.2.140.0050.02112.08
5.2.130.0060.02312.21
5.2.120.0070.03112.26
5.2.110.0030.03512.06
5.2.100.0100.03012.26
5.2.90.0040.03412.05
5.2.80.0070.03412.03
5.2.70.0040.02712.05
5.2.60.0070.02912.11
5.2.50.0070.03112.03
5.2.40.0050.03312.28
5.2.30.0000.03912.23
5.2.20.0090.01711.93
5.2.10.0080.02511.95
5.2.00.0070.01611.87
5.1.60.0020.03211.53
5.1.50.0020.01711.72
5.1.40.0060.02011.61
5.1.30.0060.02511.65
5.1.20.0030.02811.80
5.1.10.0040.01711.78
5.1.00.0040.02211.65
5.0.50.0050.01811.21
5.0.40.0080.01711.21
5.0.30.0050.02711.21
5.0.20.0020.02711.21
5.0.10.0050.02311.21
5.0.00.0020.02711.21
4.4.90.0020.01911.21
4.4.80.0050.01411.21
4.4.70.0030.01911.21
4.4.60.0040.01011.21
4.4.50.0020.01211.21
4.4.40.0000.02911.21
4.4.30.0000.01211.21
4.4.20.0040.01711.21
4.4.10.0040.01611.21
4.4.00.0030.02011.21
4.3.110.0050.01511.21
4.3.100.0020.01311.21
4.3.90.0020.01011.21
4.3.80.0030.01911.21
4.3.70.0020.00811.21
4.3.60.0020.01011.21
4.3.50.0020.01811.21
4.3.40.0040.02711.21
4.3.30.0020.01011.21
4.3.20.0020.01811.21
4.3.10.0000.01811.21
4.3.00.0000.01611.21

preferences:
41.44 ms | 401 KiB | 5 Q