3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class DAL { function getNoAnnonces() { return array( "12334", "233455" ); } function getURLRecherches() { //$line = "Nissan, Rogue, 2008, 1000, 9000, 10000, 110000"; //$line2 = "Nissan, Rogue, 2009, 1000, 9000, 10000, 90000"; return array( "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000", "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000" //split(",", $line, 7), //split(",", $line2, 7) ); } } class AdsListExtractor { private $html; function __construct($a1) { $this->html = $a1; echo $this->html; echo "\n"; } function getURLs() { $regexa = '/\<a(.*)\<\/a\>/'; preg_match($regexa, $this->html, $matches); $a = $matches[1]; //echo $a; //echo "\n"; //echo "\n"; //Extract no d'annonces $regexno = '/name="(\d+)"/i'; preg_match($regexno, $a, $matches); //echo 'id:'; //echo $matches[1]; //echo "\n"; //Extract url des fiches $regexurl = '/href="(\S+)"/i'; preg_match($regexurl, $a, $matches); //echo 'url:'; //echo $matches[1]; echo "\n"; $url_fiche = 'http://www.kijiji.ca' . $matches[1]; echo 'AdsListExtractor.getURLs return' . $url_fiche; echo "\n"; return array( $url_fiche,$url_fiche ); } } class AdInfoExtractor { //private $html = 0; //function __construct($a1) //{ //$this->html = $a1; //} function getHMTL($html) { echo '------'.$html; $regexatt = '/\<table class="ad-attributes">(.*)\<\/table\>/'; preg_match($regexatt, $html, $matches); $a = $matches[1]; $regexcontent = '/\<div id="UserContent">(.*)\<\/div\>/'; preg_match($regexcontent, $html, $matches); $b = $matches[1]; return $a . $b; } } class HTMLReader { function getHTML($url) { echo "\n"; echo 'url::'.$url; if ($url="http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000") { echo "\n"; echo 'true'; echo "\n"; return "liste <td class=\"description\"><a href=\"/v-autos-camions/ville-de-montreal/2008-bmw-x5-suv/568081363\" class=\"title enable-search-navigation-flag\" name=\"568081363\">2008 BMW X5 SUV</a><p>"; } else { echo "\n"; echo 'false'; echo "\n"; return "fiche <table class=\"ad-attributes\">yesser</table> dfdssd <div id=\"UserContent\">good</div> dfdfdf df df"; } echo "\n"; } } $dal = new DAL(); $mail_html = ''; foreach ($dal->getURLRecherches() as $line_num => $line) { echo $line; echo "\n"; $reader = new HTMLReader(); $liste = new AdsListExtractor($reader->getHTML($line)); echo "\n"; foreach ($liste->getURLs() as $line_number => $linee) { echo "\n"; $htmlfiche = $reader->getHTML($linee); echo "\n"; $ad_info = new AdInfoExtractor(); $mail_html = $mail_html . $ad_info->getHMTL($htmlfiche); echo "\n"; } }

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.1.70.0030.01217.36
7.1.60.0000.01117.56
7.1.50.0060.01617.20
7.1.00.0030.07322.35
7.0.200.0000.01016.84
7.0.140.0100.07022.20
7.0.60.0030.04319.99
7.0.50.0130.05717.90
7.0.40.0100.08720.33
7.0.30.0330.07320.25
7.0.20.0300.08720.12
7.0.10.0130.04720.17
7.0.00.0030.04320.09
5.6.280.0130.06321.11
5.6.210.0130.07720.46
5.6.200.0030.09018.28
5.6.190.0130.08020.53
5.6.180.3630.04020.41
5.6.170.0500.06320.50
5.6.160.0130.06720.46
5.6.150.0100.06018.18
5.6.140.0030.04018.21
5.6.130.0030.05718.21
5.6.120.0070.08020.91
5.6.110.0100.08021.06
5.6.100.0170.06721.00
5.6.90.0070.08321.14
5.6.80.0070.06720.52
5.6.70.4030.04020.30
5.5.350.0100.07720.46
5.5.340.0100.07717.96
5.5.330.0000.05720.27
5.5.320.0270.06320.30
5.5.310.0300.03320.30
5.5.300.0000.08318.04
5.5.290.0000.06018.06
5.5.280.0100.08720.75
5.5.270.0030.04320.66
5.5.260.0000.04720.79
5.5.250.0070.07720.60
5.5.240.0030.04020.30
5.4.450.0500.05019.63
5.4.440.0430.06319.13
5.4.430.0530.04719.69
5.4.420.0270.06019.30
5.4.410.0370.06719.45
5.4.400.0800.00018.72
5.4.390.0770.00018.49
5.4.380.0170.06018.51
5.4.370.0270.06018.61
5.4.360.0330.04718.76
5.4.350.0300.05318.76
5.4.340.0300.04718.63
5.4.320.0070.03712.52
5.4.310.0060.04312.52
5.4.300.0070.04412.52
5.4.290.0090.04012.51
5.4.280.0080.03612.41
5.4.270.0110.03412.41
5.4.260.0030.05719.06
5.4.250.0130.07318.93
5.4.240.0100.05318.80
5.4.230.0000.08018.88
5.4.220.0130.07018.88
5.4.210.0070.08019.06
5.4.200.0130.04718.94
5.4.190.0070.05719.00
5.4.180.0070.05718.64
5.4.170.0030.06318.87
5.4.160.0170.04719.05
5.4.150.0100.05318.91
5.4.140.0100.04716.36
5.4.130.0030.05316.54
5.4.120.0030.05316.50
5.4.110.0030.05316.32
5.4.100.0170.04016.58
5.4.90.0130.06716.46
5.4.80.0030.05016.33
5.4.70.0070.04716.52
5.4.60.0230.04016.35
5.4.50.0100.04716.27
5.4.40.0070.05716.58
5.4.30.0070.05716.27
5.4.20.0100.04716.43
5.4.10.0100.05016.27
5.4.00.0030.05015.83
5.3.290.0110.04312.80
5.3.280.0000.07314.59
5.3.270.0070.08314.76
5.3.260.0130.05314.70
5.3.250.0130.04714.85
5.3.240.0070.05014.63
5.3.230.0100.05014.85
5.3.220.0130.04714.67
5.3.210.0070.05314.66
5.3.200.0070.05314.66
5.3.190.0100.04714.42
5.3.180.0100.04314.67
5.3.170.0070.05014.66
5.3.160.0130.04314.72
5.3.150.0100.06314.72
5.3.140.0200.04014.54
5.3.130.0100.05014.73
5.3.120.0100.05014.47
5.3.110.0170.04714.54
5.3.100.0130.04314.22
5.3.90.0100.04314.06
5.3.80.0130.04314.02
5.3.70.0130.04313.87
5.3.60.0070.05014.11
5.3.50.0070.05014.04
5.3.40.0130.04313.98
5.3.30.0070.04713.91
5.3.20.0030.05313.79
5.3.10.0070.04713.66
5.3.00.0130.07313.82
5.2.170.0100.03711.14
5.2.160.0100.03711.16
5.2.150.0130.03711.07
5.2.140.0070.04011.23
5.2.130.0100.03311.08
5.2.120.0000.04311.20
5.2.110.0070.04311.10
5.2.100.0100.05011.08
5.2.90.0070.03711.28
5.2.80.0000.04711.33
5.2.70.0070.03711.29
5.2.60.0070.04010.98
5.2.50.0100.03710.88
5.2.40.0100.04711.03
5.2.30.0030.04011.02
5.2.20.0130.03011.05
5.2.10.0130.03310.79
5.2.00.0000.04310.70
5.1.60.0000.0409.86
5.1.50.0030.03710.02
5.1.40.0030.0409.98
5.1.30.0030.03710.54
5.1.20.0170.02310.29
5.1.10.0000.0439.93
5.1.00.0030.03710.01
5.0.50.0070.0378.55
5.0.40.0000.0338.64
5.0.30.0070.0578.36
5.0.20.0070.0378.32
5.0.10.0030.0308.21
5.0.00.0070.0408.39
4.4.90.0000.0236.41
4.4.80.0000.0276.41
4.4.70.0000.0236.41
4.4.60.0030.0206.41
4.4.50.0000.0276.41
4.4.40.0070.0436.41
4.4.30.0100.0236.41
4.4.20.0070.0176.41
4.4.10.0030.0306.41
4.4.00.0030.0336.41
4.3.110.0000.0336.41
4.3.100.0000.0336.41
4.3.90.0000.0276.41
4.3.80.0030.0336.41
4.3.70.0030.0206.41
4.3.60.0030.0206.41
4.3.50.0070.0176.41
4.3.40.0030.0336.41
4.3.30.0000.0236.41
4.3.20.0000.0276.41
4.3.10.0000.0236.41
4.3.00.0030.0206.84