3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_time_limit(0); class StrawPoll { public function __construct() { } public function vote($id, array $votes, $amount = 10, $proxyList = null, $timeout = 5, $showErrors = true) { $mh = curl_multi_init(); $chs = array(); if(is_file($proxyList)) { $parts = pathinfo($proxyList); $json = false; if($parts['extension'] == 'json') { $proxies = json_decode(file_get_contents($proxyList), true); if($proxies) { $json = true; } else { return 'Malformed JSON in ' . $proxyList; } } else { $proxies = file($proxyList); } } $post = array( 'id' => $id, 'votes' => $votes ); $post = http_build_query($post); $headers = array( 'Origin: http://strawpoll.me', 'If-None-Match: 6bbfd', 'X-Requested-With: XMLHttpRequest' ); $loop = false; if($amount == -1) { $loop = true; $amount = 25; } if(isset($proxies)) { $amount = count($proxies); } $used = array(); for($i = 0; $i < $amount; $i++) { $ch = $this->makeCurl('http://strawpoll.me/ajax/vote'); $chs[] = $ch; if(isset($proxies)) { if(count($proxies) < 1) { if($showErrors) { echo 'Out of proxies :(' . PHP_EOL; } break; } $key = array_rand($proxies); $proxy = $proxies[$key]; unset($proxies[$key]); $proxyType = CURLPROXY_HTTP; if(!$json) { $proxy = trim($proxy); $parts = explode(':', $proxy); if(isset($parts[0], $parts[1])) { $proxyIP = $parts[0]; $proxyPort = $parts[1]; } else { $i--; continue; } if(isset($parts[2])) { $proxyType = strtoupper($proxyType) == 'SOCKS5' ? CURLPROXY_SOCKS5 : CURLPROXY_HTTP; } } else if($json && isset($proxy['ip'], $proxy['port'])) { $proxyIP = $proxy['ip']; $proxyPort = $proxy['port']; if(isset($proxy['type'])) { $proxyType = strtoupper($proxy['type']) == 'SOCKS5' ? CURLPROXY_SOCKS5 : CURLPROXY_HTTP; } } if(isset($used[$proxyIP])) { $i--; continue; } $used[$proxyIP] = true; if(!filter_var($proxyIP, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) || (!ctype_digit($proxyPort) || ($proxyPort < 0 || $proxyPort > 65535))) { $i--; continue; } curl_setopt_array($ch, array( CURLOPT_PROXY => $proxyIP . ':' . $proxyPort, CURLOPT_PROXYTYPE => $proxyType )); } curl_setopt_array($ch, array( CURLOPT_POSTFIELDS => $post, CURLOPT_POST => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_REFERER => 'http://strawpoll.me/' . $id, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36', CURLOPT_TIMEOUT => $timeout )); curl_multi_add_handle($mh, $ch); } $running = null; $votes = 0; $j = 0; $results = array(); do { while(($exec = curl_multi_exec($mh, $running)) == CURLM_CALL_MULTI_PERFORM); if($exec != CURLM_OK) { break; } while($ch = curl_multi_info_read($mh)) { $j++; $ch = $ch['handle']; $error = curl_error($ch); if(!$error) { $resp = curl_multi_getcontent($ch); $out = json_decode($resp, true); if(!isset($out['success'])) { if($showErrors) { echo 'Didn\'t vote. Invalid response.' . PHP_EOL; var_dump($resp); } } else { if($out['success'] == true) { $votes++; echo '[' . $votes . '] Voted' . PHP_EOL; } } $results[] = $out; } else { $results[] = $error; if($showErrors) { echo $error . PHP_EOL; } } curl_multi_remove_handle($mh, $ch); curl_close($ch); } } while($running); curl_multi_close($mh); if($loop) { $this->vote($id, $votes, $amount, $proxyList, $timeout); return array('results' => $results, 'votes' => $votes); } return array('results' => $results, 'votes' => $votes, 'total' => $amount); } public function makeCurl($url) { $cookie = dirname(__FILE__) . '/strawpoll.txt'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie )); return $ch; } } $sp = new StrawPoll(); $votes = $sp->vote(3251008, array(1), 10500, 'http://pastebin.com/raw.php?i=Bc38g64G', 30, true); echo 'Successfully voted ' . $votes['votes'] . '/' . $votes['total'] . ' time(s)';

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.4.10.0060.01215.15
7.4.00.0070.01115.09
7.3.130.0070.01114.63
7.3.120.0080.00914.99
7.3.110.0070.00715.10
7.3.100.0020.01414.89
7.3.90.0070.00715.09
7.3.80.0020.00814.94
7.3.70.0090.00714.69
7.3.60.0090.00314.68
7.3.50.0020.00914.96
7.3.40.0080.00414.73
7.3.30.0150.00014.93
7.3.20.0030.00816.65
7.3.10.0090.00516.41
7.3.00.0030.01016.45
7.2.260.0090.00914.95
7.2.250.0020.01515.09
7.2.240.0080.00715.33
7.2.230.0120.00315.05
7.2.220.0050.01214.95
7.2.210.0050.00615.04
7.2.200.0050.01115.06
7.2.190.0060.00814.96
7.2.180.0050.00915.02
7.2.170.0070.00815.03
7.2.160.0100.00715.20
7.2.150.0000.01416.71
7.2.140.0070.01016.89
7.2.130.0050.01116.63
7.2.120.0030.01016.66
7.2.110.0060.00816.87
7.2.100.0020.01116.64
7.2.90.0060.00316.71
7.2.80.0040.01216.82
7.2.70.0070.00516.81
7.2.60.0080.00916.70
7.2.50.0090.00516.66
7.2.40.0070.01016.68
7.2.30.0050.00816.65
7.2.20.0000.01416.79
7.2.10.0010.01116.65
7.2.00.0040.00817.69
7.1.330.0020.01215.54
7.1.320.0020.01115.64
7.1.310.0060.00815.66
7.1.300.0020.01015.61
7.1.290.0080.00315.55
7.1.280.0030.00915.54
7.1.270.0060.00515.64
7.1.260.0040.01315.68
7.1.250.0030.00815.71
7.1.240.0060.00515.68
7.1.230.0080.00615.43
7.1.220.0070.00715.76
7.1.210.0030.01015.48
7.1.200.0050.00715.61
7.1.190.0040.00915.69
7.1.180.0080.00615.67
7.1.170.0030.01015.61
7.1.160.0070.00615.55
7.1.150.0040.00915.54
7.1.140.0080.00515.57
7.1.130.0080.00615.59
7.1.120.0080.00815.69
7.1.110.0070.00215.68
7.1.100.0050.00816.49
7.1.90.0030.00615.57
7.1.80.0040.00615.66
7.1.70.0020.01016.22
7.1.60.0060.00616.93
7.1.50.0030.00815.86
7.1.40.0030.00915.56
7.1.30.0040.01215.54
7.1.20.0030.01115.66
7.1.10.0030.00915.59
7.1.00.0040.01015.74
7.0.330.0100.00315.15
7.0.320.0040.00715.28
7.0.310.0070.00515.17
7.0.300.0040.00715.13
7.0.290.0080.00615.34
7.0.280.0050.00615.16
7.0.270.0040.01015.30
7.0.260.0080.00315.35
7.0.250.0080.00315.27
7.0.240.0050.00515.42
7.0.230.0080.00315.20
7.0.220.0050.00515.09
7.0.210.0060.00815.24
7.0.200.0050.00515.74
7.0.190.0080.00615.10
7.0.180.0050.00615.30
7.0.170.0060.00715.33
7.0.160.0020.01115.34
7.0.150.0050.00715.43
7.0.140.0050.01015.15
7.0.130.0050.00515.26
7.0.120.0050.00715.25
7.0.110.0050.00815.27
7.0.100.0030.00715.26
7.0.90.0080.00715.14
7.0.80.0030.01115.39
7.0.70.0080.00315.38
7.0.60.0070.00815.30
7.0.50.0050.01015.41
7.0.40.0040.01213.22
7.0.30.0100.00513.13
7.0.20.0040.00913.47
7.0.10.0040.00613.29
7.0.00.0050.00613.29
5.6.400.0060.01214.41
5.6.390.0030.01314.20
5.6.380.0050.00914.28
5.6.370.0040.00814.51
5.6.360.0070.01114.59
5.6.350.0020.01214.44
5.6.340.0060.00514.32
5.6.330.0090.00414.43
5.6.320.0020.01114.42
5.6.310.0090.00514.18
5.6.300.0060.00614.37
5.6.290.0060.00614.47
5.6.280.0090.00314.37
5.6.270.0050.01014.38
5.6.260.0070.00814.32
5.6.250.0050.01114.21
5.6.240.0040.01314.33
5.6.230.0090.00314.42
5.6.220.0060.00914.26
5.6.210.0100.00414.44
5.6.200.0080.00614.40
5.6.190.0030.01314.11
5.6.180.0050.00914.34
5.6.170.0050.00614.17
5.6.160.0060.00614.17
5.6.150.0050.00613.99
5.6.140.0080.00314.26
5.6.130.0050.00614.38
5.6.120.0020.01114.23
5.6.110.0070.00614.32
5.6.100.0020.00914.49
5.6.90.0100.00314.26
5.6.80.0030.01314.23
5.6.70.0040.00914.29
5.6.60.0050.00914.15
5.6.50.0060.00614.21
5.6.40.0080.00714.00
5.6.30.0080.00714.19
5.6.20.0090.00414.04
5.6.10.0070.00714.20
5.6.00.0080.00514.25
5.5.380.0020.01012.66
5.5.370.0090.00312.76
5.5.360.0040.00612.59
5.5.350.0090.00012.80
5.5.340.0070.00312.51
5.5.330.0030.01012.49
5.5.320.0070.00612.61
5.5.310.0050.00512.70
5.5.300.0020.01312.53
5.5.290.0030.00612.63
5.5.280.0020.00712.48
5.5.270.0060.00212.48
5.5.260.0070.00412.55
5.5.250.0090.00912.78
5.5.240.0010.01012.49
5.5.230.0070.00612.63
5.5.220.0070.00312.58
5.5.210.0080.00512.61
5.5.200.0030.01012.60
5.5.190.0070.00512.61
5.5.180.0050.00712.76
5.5.170.0030.00912.41
5.5.160.0030.00712.51
5.5.150.0060.00612.50
5.5.140.0000.01012.53
5.5.130.0050.00412.54
5.5.120.0100.00212.51
5.5.110.0040.00712.47
5.5.100.0030.01212.59
5.5.90.0050.00912.52
5.5.80.0040.00812.43
5.5.70.0080.00212.56
5.5.60.0090.00512.60
5.5.50.0040.00712.19
5.5.40.0110.00312.47
5.5.30.0060.00612.66
5.5.20.0050.00512.74
5.5.10.0000.01212.54
5.5.00.0010.01112.43
5.4.450.0030.00512.13
5.4.440.0020.01011.90
5.4.430.0010.00811.99
5.4.420.0050.00711.97
5.4.410.0050.00911.92
5.4.400.0060.00711.93
5.4.390.0050.00611.99
5.4.380.0030.00811.78
5.4.370.0070.00512.08
5.4.360.0020.00911.87
5.4.350.0090.00511.88
5.4.340.0020.00911.85
5.4.330.0070.00311.96
5.4.320.0070.00311.97
5.4.310.0030.00611.90
5.4.300.0070.00511.96
5.4.290.0040.00511.89
5.4.280.0030.00912.02
5.4.270.0020.01212.03
5.4.260.0030.00811.99
5.4.250.0030.00612.02
5.4.240.0040.00412.04
5.4.230.0070.00511.96
5.4.220.0040.00511.92
5.4.210.0030.00912.07
5.4.200.0090.00112.06
5.4.190.0030.00511.78
5.4.180.0060.00411.92
5.4.170.0010.00611.84
5.4.160.0030.00911.93
5.4.150.0030.00811.80
5.4.140.0020.00811.83
5.4.130.0070.00511.93
5.4.120.0050.00411.88
5.4.110.0070.00211.87
5.4.100.0030.00711.72
5.4.90.0050.00611.86
5.4.80.0020.00711.99
5.4.70.0060.00311.88
5.4.60.0030.00611.81
5.4.50.0080.00311.92
5.4.40.0080.00611.82
5.4.30.0040.00411.89
5.4.20.0040.00911.76
5.4.10.0020.00811.88
5.4.00.0040.00911.99

preferences:
45.67 ms | 401 KiB | 5 Q