3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Desc: Imports new Categories into database bet3000 (expected to run once daily) */ ini_set('display_errors', 1); error_reporting(E_ALL & ~E_NOTICE); $possible_languages=array('de','en','tr','es','el','ru','fr'); $wanted_languages=array('de'); /* DB CONNECT */ $host = "localhost"; // Host name $username_mysql = "d01ff632"; // Mysql username $password_mysql = "achimundeva"; // Mysql password $db_name = "d01ff632"; // Database name /** Connect to server and select databse. * */ @mysql_connect("$host_mysql", "$username_mysql", "$password_mysql") or die("Cannot connect to database. Please edit the file settings.php"); mysql_select_db("$db_name") or die("Cannot select temp database."); mysql_query("SET NAMES 'utf8'"); /* IMPORT SPORTS CATEGORIES */ foreach ($wanted_languages as $lang) { echo "import categories for lang=$lang\n"; $url = "https://www.bet3000.com/".$lang."/jsonrpc/?jsonrpc=2.0&id=0&method=sportsbook.get_active_categories"; try { $data = file_get_contents($url); $data = json_decode($data, true); $query = "UPDATE home_categories SET active=0"; if (!$debug) { mysql_query($query); } $cat_lvl_ids[0] = array("id" => 0,"label" => ""); $prev_lvl = 0; $parent_id = 0; $index = 0; $flag = false; $sortid=0; foreach ($data ['categories'] as $key => $value){ $sortid++; $cat = new Category($value); $lvl = $cat->get_level(); $id = $cat->get_id(); $active = $cat->get_activated_id(); $cat_lvl_ids[$lvl]["id"] = $id; $parent_id = $cat_lvl_ids[$lvl-1]["id"]; $parent_lbl = ""; if(!empty($cat_lvl_ids[$lvl-1]["label"])) { $parent_lbl = $cat_lvl_ids[$lvl-1]["label"]." / "; } $path = $parent_lbl . $cat->get_label(); $cat_lvl_ids[$lvl]["label"] = $path; $explode = explode(" / ",$path); $detail = $explode[count($explode)-1]; $sport = $explode[0]; $qcheck="SELECT * FROM `home_categories` WHERE cid=".$id." AND lang='".$lang."'"; $rcheck=mysql_query($qcheck); if (mysql_num_rows($rcheck)>0) { $ocheck=mysql_fetch_object($rcheck); $sqladd =""; $sqladd.= ",path='".trim(mysql_real_escape_string($path))."', detail='".trim(mysql_real_escape_string($detail))."'"; // UPDATE path,detail,sortid,active $querynew="UPDATE home_categories SET active=".$active.",sortid=".$sortid.$sqladd." WHERE cid=".$id." AND lang='".$lang."'"; mysql_query($querynew); echo mysql_error(); } else { $sqlheaderadd=""; $sqladd =""; $query = "INSERT IGNORE INTO `home_categories` (cid,lang,detail,path,topcatid,stufe,sport,sortid,active) VALUES (". $id.", ". "'".$lang."', ". "'".trim(mysql_real_escape_string($detail))."', ". "'".trim(mysql_real_escape_string($path))."', ". $parent_id.", ". $lvl.", ". "'".trim(mysql_real_escape_string($sport))."', ". $sortid.", ". $active. ")"; $resultInsert = mysql_query($query); if(!$resultInsert) echo mysql_error()."<br>$query"; } $prev_lvl = $lvl; } //foreach($result as $v) { // echo $value."<br>"; //} } catch(Exception $e) { echo $e->getMessage(); } } echo 'Categories added to database'; class Category { private $id; private $lvl; private $label; private $activated_id; private $children; public function __construct($cat) { $this->id = $cat['id']; $this->lvl = $cat['level']; $this->label = $cat['label']; $this->activated_id = $cat['activated_id']; $this->children = array(); } public function get_id() { return $this->id; } public function get_level() { return $this->lvl; } public function get_label() { return $this->label; } public function get_activated_id() { return $this->activated_id; } public function get_children() { return $this->children; } public function set_id($id) { $this->id = $id; } public function set_level($lvl) { $this->lvl = $lvl; } public function set_label($label) { $this->label = $label; } public function set_children($children) { $this->children = $children; } public function add_child($child) { $this->children[] = $child; } public function get_child($index) { return $this->children[$index]; } public function remove_child($child,$index) { $this->children[] = null; } public function __toString() { return "Category Lvl:".$this->get_level()." - ".$this->get_id(). ":".$this->get_label(); } }

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.3.00.0030.00916.60
7.2.130.0070.01016.93
7.2.120.0070.01016.79
7.2.110.0030.01016.94
7.2.100.0100.00316.69
7.2.90.0030.00616.66
7.2.80.0090.00616.86
7.2.70.0060.00916.63
7.2.60.0060.00516.68
7.2.50.0030.00916.82
7.2.40.0040.01216.65
7.2.30.0030.01017.02
7.2.20.0100.00316.64
7.2.10.0090.00616.80
7.2.00.0050.00818.07
7.1.250.0090.00615.69
7.1.240.0030.00615.66
7.1.230.0070.00715.74
7.1.220.0060.00815.58
7.1.210.0060.00615.84
7.1.200.0050.01015.75
7.1.190.0140.00015.52
7.1.180.0030.01015.54
7.1.170.0070.00715.92
7.1.160.0060.00815.73
7.1.150.0030.01015.85
7.1.140.0030.01015.51
7.1.130.0040.01115.82
7.1.120.0080.00415.51
7.1.110.0110.00315.67
7.1.100.0030.00917.00
7.1.90.0080.00415.81
7.1.80.0000.01015.84
7.1.70.0040.00716.47
7.1.60.0070.01317.66
7.1.50.0060.01116.21
7.1.40.0040.01115.85
7.1.30.0040.00815.75
7.1.20.0040.00815.74
7.1.10.0060.00315.83
7.1.00.0040.04219.00
7.0.330.0110.00315.29
7.0.320.0080.00315.39
7.0.310.0060.00915.39
7.0.300.0100.00315.36
7.0.290.0100.00015.31
7.0.280.0120.00015.44
7.0.270.0030.01015.31
7.0.260.0070.00715.15
7.0.250.0060.00615.55
7.0.240.0120.00415.54
7.0.230.0030.00915.52
7.0.220.0070.00415.18
7.0.210.0090.00615.30
7.0.200.0060.00516.06
7.0.190.0030.01315.25
7.0.180.0060.00615.38
7.0.170.0060.00615.18
7.0.160.0060.00615.04
7.0.150.0030.01015.47
7.0.140.0070.00715.39
7.0.130.0120.00015.29
7.0.120.0000.00815.41
7.0.110.0000.01615.50
7.0.100.0050.05017.64
7.0.90.0100.04017.73
7.0.80.0150.04017.66
7.0.70.0100.04717.64
7.0.60.0070.04017.71
7.0.50.0100.04017.81
7.0.40.0040.03016.77
7.0.30.0100.04216.83
7.0.20.0090.02816.68
7.0.10.0070.04416.63
7.0.00.0070.04216.71
5.6.380.0040.01114.55
5.6.370.0070.00714.40
5.6.360.0000.01614.25
5.6.350.0080.00814.38
5.6.340.0040.00814.48
5.6.330.0040.00814.18
5.6.320.0070.00314.25
5.6.310.0060.00814.49
5.6.300.0030.01014.55
5.6.290.0030.01014.33
5.6.280.0030.01917.50
5.6.270.0000.01014.01
5.6.260.0030.01013.94
5.6.250.0070.04217.66
5.6.240.0080.03817.52
5.6.230.0070.04617.45
5.6.220.0120.04217.60
5.6.210.0100.04317.35
5.6.200.0080.04217.88
5.6.190.0030.04117.94
5.6.180.0050.04617.84
5.6.170.0150.04217.55
5.6.160.0040.04017.68
5.6.150.0050.03717.80
5.6.140.0070.04317.78
5.6.130.0060.04817.70
5.6.120.0030.04817.63
5.6.110.0070.04817.56
5.6.100.0100.04017.68
5.6.90.0100.02617.75
5.6.80.0090.04417.40
5.6.70.0080.03317.42
5.6.60.0020.03117.29
5.6.50.0090.04217.42
5.6.40.0100.04017.32
5.6.30.0100.03917.26
5.6.20.0120.02517.31
5.6.10.0050.04417.28
5.6.00.0030.04417.37
5.5.380.0060.02815.97
5.5.370.0080.04215.86
5.5.360.0070.04315.88
5.5.350.0090.02615.82
5.5.340.0050.05016.04
5.5.330.0100.03816.13
5.5.320.0070.04216.07
5.5.310.0130.04216.05
5.5.300.0100.04015.99
5.5.290.0070.03715.99
5.5.280.0060.04515.98
5.5.270.0050.04416.13
5.5.260.0120.02816.00
5.5.250.0070.04215.95
5.5.240.0080.03415.77
5.5.230.0080.04115.76
5.5.220.0050.02715.73
5.5.210.0090.04015.73
5.5.200.0090.04015.69
5.5.190.0120.02215.72
5.5.180.0120.03815.68
5.5.170.0030.00711.21
5.5.160.0040.04215.65
5.5.150.0080.04215.75
5.5.140.0080.04015.64
5.5.130.0050.04415.72
5.5.120.0050.03015.72
5.5.110.0050.04315.68
5.5.100.0070.04315.69
5.5.90.0030.04015.65
5.5.80.0050.03915.64
5.5.70.0070.03915.66
5.5.60.0040.03415.68
5.5.50.0080.03715.67
5.5.40.0030.03815.68
5.5.30.0110.02815.59
5.5.20.0130.03615.58
5.5.10.0030.04515.59
5.5.00.0030.04315.58