3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DeterministicRandom { protected $counter; public function __construct(string $seed = '', int $counter = 0) { $this->seed('set', $seed); $this->counter = 0; } private function seed(string $action = 'get', string $data = '') { static $seed = null; if ($action === 'set') { $seed = $data; } elseif ($action === 'get') { return $data; } else { throw new \Error( 'Unknown action' ); } } public function getBytes(int $numBytes): string { return \openssl_encrypt( \str_repeat("\0", $numBytes), 'aes-128-ctr', $this->seed('get'), OPENSSL_RAW_DATA, $this->getNonce($numBytes) ); } public function getInt(int $min, int $max): int { /** * @todo */ return 0; } protected function getNonce(int $increment = 0): string { $nonce = ''; $ctr = $this->counter; while ($ctr > 0) { $nonce = \chr($ctr & 0xFF) . $nonce; $ctr >>= 8; } $this->counter += $increment; return \str_pad($nonce, 16, "\0", STR_PAD_LEFT); } } $seed = str_repeat("\x80", 16); $rnd1 = new DeterministicRandom($seed); $rnd2 = new DeterministicRandom($seed); $out1 = $rnd1->getBytes(16); $out2 = $rnd1->getBytes(16); $out3 = $rnd2->getBytes(32); var_dump([ bin2hex($out1), bin2hex($out2), bin2hex($out3) ]);

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.00716.62
8.3.50.0070.01416.56
8.3.40.0180.00418.84
8.3.30.0120.00318.76
8.3.20.0050.00320.13
8.3.10.0040.00421.60
8.3.00.0050.00523.84
8.2.180.0200.00018.54
8.2.170.0090.00919.10
8.2.160.0140.00022.96
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00819.72
8.2.120.0070.00026.35
8.2.110.0030.00721.00
8.2.100.0110.00017.91
8.2.90.0030.00518.03
8.2.80.0060.00318.16
8.2.70.0040.00417.93
8.2.60.0000.01017.93
8.2.50.0060.00318.10
8.2.40.0030.00620.42
8.2.30.0080.00019.50
8.2.20.0000.00717.79
8.2.10.0000.00718.11
8.2.00.0030.00518.09
8.1.270.0080.00024.00
8.1.260.0000.00828.09
8.1.250.0080.00028.09
8.1.240.0090.00020.91
8.1.230.0040.00820.89
8.1.220.0050.00317.75
8.1.210.0040.00418.79
8.1.200.0040.00417.36
8.1.190.0040.00717.13
8.1.180.0050.00318.10
8.1.170.0000.00818.39
8.1.160.0040.00422.16
8.1.150.0000.00718.99
8.1.140.0030.00619.60
8.1.130.0000.00717.79
8.1.120.0040.00417.53
8.1.110.0040.00417.42
8.1.100.0000.00717.34
8.1.90.0040.00417.48
8.1.80.0000.00717.46
8.1.70.0000.00717.46
8.1.60.0040.00417.62
8.1.50.0030.00617.60
8.1.40.0000.00817.46
8.1.30.0040.00417.66
8.1.20.0080.00017.58
8.1.10.0080.00017.60
8.1.00.0000.00917.58
8.0.300.0040.00420.03
8.0.290.0070.00016.75
8.0.280.0080.00018.40
8.0.270.0040.00417.21
8.0.260.0030.00317.36
8.0.250.0030.00317.13
8.0.240.0000.00716.89
8.0.230.0040.00417.03
8.0.220.0030.00316.96
8.0.210.0060.00316.98
8.0.200.0030.00317.07
8.0.190.0040.00417.09
8.0.180.0000.00716.98
8.0.170.0000.00817.00
8.0.160.0080.00016.97
8.0.150.0030.00316.86
8.0.140.0080.00316.82
8.0.130.0030.00313.43
8.0.120.0000.00817.01
8.0.110.0000.00717.01
8.0.100.0040.00417.05
8.0.90.0000.00716.89
8.0.80.0040.01116.88
8.0.70.0000.00816.95
8.0.60.0040.00416.81
8.0.50.0030.00617.03
8.0.30.0140.00517.17
8.0.20.0070.01217.40
8.0.10.0070.00017.13
8.0.00.0100.00916.88
7.4.330.0030.00316.79
7.4.320.0000.00616.54
7.4.300.0000.00816.39
7.4.290.0000.00716.56
7.4.280.0060.00316.45
7.4.270.0000.00716.69
7.4.260.0070.00316.49
7.4.250.0070.00016.49
7.4.240.0040.00416.56
7.4.230.0000.00716.53
7.4.220.0100.00716.58
7.4.210.0100.00816.62
7.4.200.0070.00016.64
7.4.160.0030.01216.76
7.4.150.0070.01017.40
7.4.140.0090.00917.86
7.4.130.0110.00616.63
7.4.120.0050.01416.60
7.4.110.0060.01216.55
7.4.100.0100.00716.60
7.4.90.0120.00616.37
7.4.80.0140.00319.39
7.4.70.0100.01316.59
7.4.60.0040.01216.50
7.4.50.0030.01316.45
7.4.40.0130.00316.55
7.4.30.0100.00616.35
7.4.00.0070.00714.79
7.3.330.0020.00213.44
7.3.320.0030.00313.48
7.3.310.0040.00416.40
7.3.300.0000.00716.46
7.3.290.0000.00716.34
7.3.280.0050.01116.51
7.3.270.0100.01317.40
7.3.260.0140.00316.47
7.3.250.0130.00916.57
7.3.240.0070.01216.57
7.3.230.0150.00316.39
7.3.210.0090.01216.43
7.3.200.0070.01019.39
7.3.190.0060.00916.59
7.3.180.0100.01016.44
7.3.170.0130.00916.47
7.3.160.0110.00616.46
7.2.330.0060.01216.66
7.2.320.0060.01216.61
7.2.310.0070.01016.63
7.2.300.0130.01016.71
7.2.290.0150.00316.55
7.2.60.0060.00616.94
7.2.00.0030.00919.47
7.1.200.0000.01415.82
7.1.100.0040.00818.44
7.1.70.0000.00817.04
7.1.60.0060.01819.30
7.1.50.0070.01717.12
7.1.00.0030.07022.39
7.0.200.0000.00716.75
7.0.60.0200.07721.76
7.0.50.0070.04317.98
7.0.40.0130.07720.24
7.0.30.0070.05020.23
7.0.20.0270.07720.14
7.0.10.0000.06020.30
7.0.00.0100.08020.28
5.6.280.0070.04021.09
5.6.210.0100.07020.67
5.6.200.0100.03318.27
5.6.190.0030.06720.46
5.6.180.0400.04320.61
5.6.170.0270.08020.54
5.6.160.0070.03720.57
5.6.150.0000.04718.27
5.6.140.0130.07318.18
5.6.130.0030.07318.28
5.6.120.0070.04721.01
5.6.110.0070.06721.11
5.6.100.0070.08020.95
5.6.90.0030.09321.12
5.6.80.0070.07720.39
5.5.350.0100.05720.53
5.5.340.0100.07718.04
5.5.330.0030.08320.27
5.5.320.0200.04320.29
5.5.310.0330.06020.19
5.5.300.0070.08317.92
5.5.290.0000.04318.08
5.5.280.0030.04020.87
5.5.270.0030.04320.94
5.5.260.0130.03720.84
5.5.250.0100.08020.70
5.5.240.0300.05320.28

preferences:
69.28 ms | 400 KiB | 5 Q