3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ChampionGG { private $manaless = array("Aatrox", "DrMundo", "Mordekaiser", "Vladimir", "Zac", "Akali", "Kennen", "LeeSin", "Shen", "Zed", "Garen", "Gnar", "Katarina", "RekSai", "Renekton", "Rengar", "Riven", "Rumble", "Shyvana", "Tryndamere", "Yasuo"); public function getAllSets() { echo "Creating item sets for all champions...\n"; $time = time(); $saveFolder = $time . "_ItemSets"; $page = $this->getPage("http://champion.gg/"); preg_match_all('/<a href="([^"]*)" style="display:block">/si', $page, $list); foreach ($list[1] as $champPage) { $data = explode("/", $champPage); $champ = $data[2]; $role = $data[3]; $this->getOneSet($champ, $role, $saveFolder, $time); } echo "Complete!\n"; return true; } public function getOneSet($champ, $role, $saveFolder = null, $time = null) { if ($time == null) { $time = time(); } $url = "http://champion.gg/champion/" . $champ . "/" . $role; $page = $this->getPage($url); $data = $this->getBetween($page, "matchupData.championData = ", "matchupData.patchHistory"); $data = trim($data); $data = trim($data, ";"); $champJSON = json_decode($data, true); $currentPatch = $this->getBetween(str_replace(array("\n", " "), "", $page), "<small>Patch<strong>", "</strong>"); $firstMG = $champJSON["firstItems"]["mostGames"]; $firstHWP = $champJSON["firstItems"]["highestWinPercent"]; $fullMG = $champJSON["items"]["mostGames"]; $fullHWP = $champJSON["items"]["highestWinPercent"]; $skillsMG = $champJSON["skills"]["mostGames"]; $skillsHWP = $champJSON["skills"]["highestWinPercent"]; if (!isset($firstMG["games"], $firstHWP["games"], $fullMG["games"], $fullHWP["games"])) { echo "Woops, full data is unavailable for " . $champ . " in " . $role . " role\n"; file_put_contents($time . "_Unavailable.txt", "* " . $champ . " - " . $role . " role\n", FILE_APPEND); return false; } $consumeItems = array(2003, 2004, 2044, 2043, 2041, 2138, 2137, 2139, 2140); $trinketItems = array(3340, 3341, 3342); if (in_array($champ, $this->manaless)) { unset($consumeItems[1]); } $skillsItems1 = array(3361, 3362, 2003 /* health pot needed here so it works in other maps */); $skillsItems2 = array(3364, 3363, 2003); $skillsItemsComb = array(3361, 3362, 3364, 3363, 2003); $firstMGItems = array_merge($this->getItems($firstMG), $this->getItems($trinketItems, true)); $firstHWPItems = array_merge($this->getItems($firstHWP), $this->getItems($trinketItems, true)); $fullMGItems = $this->getItems($fullMG); $fullHWPItems = $this->getItems($fullHWP); $firstMGBlock = array( "items" => $firstMGItems, "type" => "Most Frequent Starters (" . $firstMG["winPercent"] . "% win - " . $firstMG["games"] . " games)" ); $firstHWPBlock = array( "items" => $firstHWPItems, "type" => "Highest Win Rate Starters (" . $firstHWP["winPercent"] . "% win - " . $firstHWP["games"] . " games)" ); $fullMGBlock = array( "items" => $fullMGItems, "type" => "Most Frequent Build (" . $fullMG["winPercent"] . "% win - " . $fullMG["games"] . " games)" ); $fullHWPBlock = array( "items" => $fullHWPItems, "type" => "Highest Win Rate Build (" . $fullHWP["winPercent"] . "% win - " . $fullHWP["games"] . " games)" ); $consumeBlock = array( "items" => $this->getItems($consumeItems, true), "type" => "Consumables" ); $skillsMGOrder = $this->getSkills($skillsMG); $skillsHWPOrder = $this->getSkills($skillsHWP); $skillsMGBlock = array( "items" => $this->getItems($skillsItems1, true), "type" => $skillsMGOrder . " (" . $skillsMG["winPercent"] . "% win - " . $skillsMG["games"] . " games)" ); $skillsHWPBlock = array( "items" => $this->getItems($skillsItems2, true), "type" => $skillsHWPOrder . " (" . $skillsHWP["winPercent"] . "% win - " . $skillsHWP["games"] . " games)" ); $roleFormatted = substr($champJSON["role"], 0, 1) . substr(strtolower($champJSON["role"]), 1); $itemSetArr = array( "map" => "any", "isGlobalForChampions" => false, "blocks" => array( $firstMGBlock, $firstHWPBlock, $fullMGBlock, $fullHWPBlock, $consumeBlock, $skillsMGBlock, $skillsHWPBlock ), "associatedChampions" => array(), "title" => $roleFormatted . " " . $currentPatch, "priority" => false, "mode" => "any", "isGlobalForMaps" => true, "associatedMaps" => array(), "type" => "custom", "sortrank" => 1, "champion" => $champJSON["key"] ); if ($skillsMGOrder == $skillsHWPOrder) { array_pop($itemSetArr["blocks"]); $itemSetArr["blocks"][5]["items"] = $this->getItems($skillsItemsComb, true); } if ($firstMGItems == $firstHWPItems) { unset($itemSetArr["blocks"][1]); } if ($fullMGItems == $fullHWPItems) { unset($itemSetArr["blocks"][3]); } $itemSetArr["blocks"] = array_values($itemSetArr["blocks"]); if ($saveFolder == null) { $saveFolder = $champJSON["key"] . "/Recommended"; } else { $saveFolder = $saveFolder . "/" . $champJSON["key"] . "/Recommended"; } if (!file_exists($saveFolder)) { mkdir($saveFolder, 0777, true); } $fileName = str_replace(".", "_", $currentPatch) . "_" . $roleFormatted . ".json"; $fileName = $saveFolder . "/" . $fileName; $itemSetJSON = json_encode($itemSetArr, JSON_PRETTY_PRINT); file_put_contents($fileName, $itemSetJSON); echo "Saved set for " . $champ . " in " . $role . " role to: " . $fileName . "\n"; return true; } private function getSkills($array) { $skillStr = ""; foreach ($array["order"] as $index => $skill) { $level = $index + 1; $skill = strtr($skill, array( "1" => "Q", "2" => "W", "3" => "E", "4" => "R" )); if ($level == 6 || $level == 12) { $skill .= " > "; } $skillStr .= $skill; } return $skillStr; } private function getItems($array, $fromPreset = false) { $items = array(); if ($fromPreset) { foreach ($array as $item) { $items[] = array( "count" => 1, "id" => (string) $item ); } } else { $itemIDs = array(); foreach ($array["items"] as $item) { $id = $item["id"]; if ($id == 2010) { $id = 2003; } if (isset($itemIDs[$id])) { $itemIDs[$id]++; } else { $itemIDs[$id] = 1; } } foreach ($itemIDs as $itemID => $count) { $items[] = array( "count" => $count, "id" => (string) $itemID ); } } return $items; } private function getBetween($content, $start, $end){ $r = explode($start, $content); if (isset($r[1])) { $r = explode($end, $r[1]); return $r[0]; } return ''; } private function getPage($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $data = curl_exec($ch); return $data; } } $champ = new ChampionGG(); //$champ->getOneSet("Bard", "Support"); $champ->getAllSets(); ?>

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)
7.3.10.0110.00316.31
7.3.00.0000.01116.52
7.2.130.0060.00616.59
7.2.120.0000.01116.85
7.2.110.0110.00416.82
7.2.100.0030.00616.42
7.2.90.0090.00316.77
7.2.80.0060.00716.68
7.2.70.0070.00316.88
7.2.60.0060.00916.78
7.2.50.0060.00616.84
7.2.40.0220.00016.77
7.2.30.0060.00616.68
7.2.20.0030.01016.48
7.2.10.0060.00316.93
7.2.00.0050.00918.18
7.1.250.0070.01315.51
7.1.200.0000.01615.80
7.1.100.0000.01418.13
7.1.70.0000.00817.07
7.1.60.0030.02119.42
7.1.50.0100.00716.84
7.1.00.0030.07322.31
7.0.200.0000.00916.48
7.0.100.0130.06720.11
7.0.90.0100.04320.01
7.0.80.0130.06320.11
7.0.70.0070.08720.11
7.0.60.0100.05320.02
7.0.50.0070.08720.54
7.0.40.0070.08320.10
7.0.30.0100.04320.15
7.0.20.0170.07020.09
7.0.10.0100.09020.14
7.0.00.0100.05320.07
5.6.280.0070.04721.07
5.6.250.0130.06020.68
5.6.240.0130.04320.68
5.6.230.0070.08320.76
5.6.220.0030.08320.74
5.6.210.0100.08020.69
5.6.200.0070.06721.23
5.6.190.0070.06321.13
5.6.180.0030.05321.11
5.6.170.0130.07721.15
5.6.160.0070.04321.20
5.6.150.0070.09021.10
5.6.140.0130.05021.17
5.6.130.0170.07021.19
5.6.120.0070.07721.21
5.6.110.0130.07021.17
5.6.100.0030.08021.19
5.6.90.0070.08321.10
5.6.80.0100.03320.52
5.6.70.0070.08020.63
5.6.60.0070.07320.41
5.6.50.0100.07720.51
5.6.40.0070.07720.38
5.6.30.0070.07320.54
5.6.20.0100.08320.45
5.6.10.0100.07320.44
5.6.00.0030.04720.49
5.5.380.0000.08720.49
5.5.370.0200.03320.60
5.5.360.0100.03720.40
5.5.350.0000.08720.52
5.5.340.0130.08020.86
5.5.330.0100.08020.99
5.5.320.0030.05020.92
5.5.310.0030.05020.86
5.5.300.0070.05020.98
5.5.290.0130.07320.82
5.5.280.0100.05720.88
5.5.270.0030.05320.88
5.5.260.0170.07720.82
5.5.250.0200.07320.79
5.5.240.0100.07720.37
5.5.230.0100.05720.33
5.5.220.0070.07720.25
5.5.210.0100.04720.36
5.5.200.0030.08320.12
5.5.190.0070.05020.25
5.5.180.0100.04320.27
5.5.160.0030.08020.19
5.5.150.0030.08020.32
5.5.140.0030.08320.34
5.5.130.0130.07320.30
5.5.120.0030.04020.30
5.5.110.0070.06320.21
5.5.100.0070.07720.18
5.5.90.0100.03320.23
5.5.80.0030.08320.13
5.5.70.0030.09020.12
5.5.60.0000.05320.18
5.5.50.0130.06320.13
5.5.40.0070.04020.17
5.5.30.0170.07720.21
5.5.20.0030.04720.16
5.5.10.0070.07720.14
5.5.00.0030.05020.17
5.4.450.0100.08319.46
5.4.440.0000.05319.54
5.4.430.0100.04319.35
5.4.420.0200.07019.21
5.4.410.0030.04719.31
5.4.400.0100.07719.24
5.4.390.0030.08319.12
5.4.380.0030.08019.09
5.4.370.0070.05019.09
5.4.360.0000.08019.19
5.4.350.0070.06319.18
5.4.340.0170.06718.85
5.4.320.0170.05319.13
5.4.310.0130.07019.05
5.4.300.0100.06719.02
5.4.290.0170.06319.07
5.4.280.0100.05018.96
5.4.270.0070.06318.89
5.4.260.0100.08719.21
5.4.250.0100.04019.11
5.4.240.0070.07019.12
5.4.230.0030.07719.06
5.4.220.0070.08319.15
5.4.210.0100.06319.12
5.4.200.0000.07318.82
5.4.190.0170.07019.02
5.4.180.0070.05319.12
5.4.170.0170.07019.18
5.4.160.0100.07319.00
5.4.150.0030.05019.00
5.4.140.0100.05316.34
5.4.130.0030.07016.43
5.4.120.0100.04016.42
5.4.110.0030.08016.56
5.4.100.0030.07716.40
5.4.90.0070.04716.56
5.4.80.0130.06016.54
5.4.70.0130.07016.39
5.4.60.0030.07716.31
5.4.50.0030.07316.46
5.4.40.0070.07016.46
5.4.30.0100.07316.52
5.4.20.0030.07716.43
5.4.10.0230.06316.51
5.4.00.0030.07715.86

preferences:
39.04 ms | 401 KiB | 5 Q