3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /* * This file is part of Guzzle Factory. * * (c) Graham Campbell <graham@alt-three.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace GrahamCampbell\GuzzleFactory; use GuzzleHttp\Client; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\TransferException; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** * This is the guzzle factory class. * * @author Graham Campbell <graham@alt-three.com> */ final class GuzzleFactory { /** * The default connect timeout. * * @var int */ const CONNECT_TIMEOUT = 10; /** * The default connect timeout. * * @var int */ const TIMEOUT = 15; /** * The default backoff multiplier. * * @var int */ const BACKOFF = 1000; /** * The default 4xx retry codes. * * @var int[] */ const CODES = [429]; /** * Create a new guzzle client. * * @param array $options * @param int|null $backoff * @param int[]|null $codes * * @return \GuzzleHttp\Client */ public static function make(array $options = [], int $backoff = null, array $codes = null) { return new Client(array_merge(['handler' => self::handler($backoff, $codes), 'connect_timeout' => self::CONNECT_TIMEOUT, 'timeout' => self::TIMEOUT], $options)); } /** * Create a new guzzle handler stack. * * @param int|null $backoff * @param int[]|null $codes * * @return \GuzzleHttp\Client */ public static function handler(int $backoff = null, array $codes = null) { $stack = HandlerStack::create(); $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) { return $retries < 3 && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || in_array($codes === null ? self::CODES : $codes, $response->getStatusCode())))); }, function ($retries) use ($backoff) { return (int) pow(2, $retries) * ($backoff === null ? self::BACKOFF : $backoff); })); return $stack; } }

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.60.0110.00718.18
8.3.50.0100.01016.20
8.3.40.0040.01118.54
8.3.30.0120.00618.59
8.3.20.0030.00621.59
8.3.10.0040.00421.86
8.3.00.0060.00320.65
8.2.180.0040.01118.29
8.2.170.0120.00922.96
8.2.160.0030.01522.25
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00022.26
8.2.120.0050.00326.35
8.2.110.0090.00019.20
8.2.100.0110.00017.78
8.2.90.0030.00517.72
8.2.80.0000.00819.38
8.2.70.0000.00817.68
8.2.60.0050.00317.97
8.2.50.0070.00418.10
8.2.40.0000.00820.67
8.2.30.0050.00219.20
8.2.20.0000.00817.85
8.2.10.0040.00417.91
8.2.00.0040.00418.00
8.1.280.0110.01125.92
8.1.270.0030.00522.04
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0000.00823.99
8.1.230.0090.00320.96
8.1.220.0000.00917.74
8.1.210.0050.00318.77
8.1.200.0060.00317.10
8.1.190.0050.00317.00
8.1.180.0080.00018.10
8.1.170.0040.00418.52
8.1.160.0000.00818.77
8.1.150.0060.00322.06
8.1.140.0040.00419.43
8.1.130.0000.00718.69
8.1.120.0000.00817.34
8.1.110.0030.00517.29
8.1.100.0040.00417.28
8.1.90.0060.00317.23
8.1.80.0050.00317.35
8.1.70.0030.00517.25
8.1.60.0030.00517.50
8.1.50.0060.00317.42
8.1.40.0000.00817.31
8.1.30.0040.00417.44
8.1.20.0050.00317.57
8.1.10.0040.00417.41
8.1.00.0040.00417.23
8.0.300.0040.00419.75
8.0.290.0060.00316.63
8.0.280.0000.00718.25
8.0.270.0070.00017.13
8.0.260.0080.00016.71
8.0.250.0040.00416.76
8.0.240.0060.00316.83
8.0.230.0000.00716.83
8.0.220.0040.00416.87
8.0.210.0000.00716.75
8.0.200.0000.00616.86
8.0.190.0080.00016.82
8.0.180.0040.00416.68
8.0.170.0070.00416.70
8.0.160.0000.00816.86
8.0.150.0070.00016.76
8.0.140.0000.00816.63
8.0.130.0000.00613.18
8.0.120.0030.00616.76
8.0.110.0050.00216.73
8.0.100.0040.00416.61
8.0.90.0030.00316.63
8.0.80.0140.00316.79
8.0.70.0040.00416.76
8.0.60.0000.00716.57
8.0.50.0040.00416.80
8.0.30.0120.00716.74
8.0.20.0080.01317.40
8.0.10.0070.00016.80
8.0.00.0030.01416.74
7.4.330.0000.00515.55
7.4.320.0000.00716.46
7.4.300.0030.00316.53
7.4.290.0030.00616.34
7.4.280.0000.01016.24
7.4.270.0030.00316.37
7.4.260.0060.00013.18
7.4.250.0000.00816.24
7.4.240.0000.00816.51
7.4.230.0070.00016.23
7.4.220.0070.01016.49
7.4.210.0090.00616.33
7.4.200.0030.00316.48
7.4.160.0080.00816.31
7.4.150.0090.00917.40
7.4.140.0110.00917.86
7.4.130.0150.00416.48
7.4.120.0100.00816.33
7.4.110.0000.01716.43
7.4.100.0030.01316.29
7.4.90.0100.00716.49
7.4.80.0090.01419.39
7.4.70.0040.01216.19
7.4.60.0060.01216.12
7.4.50.0080.00516.28
7.4.40.0140.00316.32
7.4.30.0110.00716.54
7.4.00.0030.01414.57
7.3.330.0060.00013.18
7.3.320.0000.00513.03
7.3.310.0030.00316.19
7.3.300.0000.00616.16
7.3.290.0090.00716.20
7.3.280.0060.00916.18
7.3.270.0120.00617.40
7.3.260.0110.01116.25
7.3.250.0080.01216.28
7.3.240.0100.01216.24
7.3.230.0090.00916.33
7.3.210.0060.01516.45
7.3.200.0060.01216.18
7.3.190.0060.01016.50
7.3.180.0130.00316.13
7.3.170.0050.01416.34
7.3.160.0060.01216.41
7.2.330.0070.01016.46
7.2.320.0140.01116.43
7.2.310.0030.01316.41
7.2.300.0150.00316.64
7.2.290.0100.00716.57
7.2.80.0060.00616.69
7.2.60.0100.00416.96
7.2.50.0060.00616.58
7.1.200.0060.00815.25
7.1.70.0020.00517.13
7.1.60.0700.01032.94
7.1.50.0600.01032.61
7.1.40.0530.01032.62
7.1.30.0630.01032.43
7.1.20.0530.01332.71
7.1.10.0430.01314.75
7.1.00.0370.01014.60
7.0.200.0730.00714.79
7.0.190.0570.00714.78
7.0.180.0470.01014.34
7.0.170.0700.01014.37
7.0.160.0500.00714.18
7.0.150.0500.00314.30
7.0.140.0400.01014.48
7.0.130.0400.01314.40
7.0.120.0500.00714.70
7.0.110.0370.01314.57
7.0.100.0500.01714.38
7.0.90.1230.01014.37
7.0.80.0430.00314.46
7.0.70.0370.01014.33
7.0.60.0370.01014.26
7.0.50.0400.01014.47
7.0.40.0400.01314.69
7.0.30.0400.01014.45
7.0.20.0330.01314.38
7.0.10.0400.00714.55
7.0.00.0430.00714.40

preferences:
68.24 ms | 400 KiB | 5 Q