3v4l.org

run code in 300+ PHP versions simultaneously
<?php function crypto_rand_secure($min, $max) { $range = $max - $min; if ($range < 0) return $min; // not so random... $log = log($range, 2); $bytes = (int) ($log / 8) + 1; // length in bytes $bits = (int) $log + 1; // length in bits $filter = (int) (1 << $bits) - 1; // set all lower bits to 1 do { $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes))); $rnd = $rnd & $filter; // discard irrelevant bits } while ($rnd >= $range); return $min + $rnd; } function getToken($length){ $token = ""; $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $codeAlphabet.= "abcdefghijklmnopqrstuvwxyz"; $codeAlphabet.= "0123456789"; for($i=0;$i<$length;$i++){ $token .= $codeAlphabet[crypto_rand_secure(0,strlen($codeAlphabet))]; } return $token; } echo getToken(23);

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.0120.00918.32
8.3.50.0190.00222.11
8.3.40.0150.00618.92
8.3.30.0140.00020.30
8.3.20.0000.00820.33
8.3.10.0040.00422.04
8.3.00.0040.00422.39
8.2.180.0110.00725.92
8.2.170.0120.00319.04
8.2.160.0070.01022.96
8.2.150.0070.00025.66
8.2.140.0050.00324.66
8.2.130.0070.01126.16
8.2.120.0080.00019.66
8.2.110.0000.00922.20
8.2.100.0090.00319.42
8.2.90.0000.00819.20
8.2.80.0000.00819.43
8.2.70.0000.00817.88
8.2.60.0090.00017.93
8.2.50.0050.00318.07
8.2.40.0030.00618.16
8.2.30.0030.00518.12
8.2.20.0040.00417.90
8.2.10.0040.00417.89
8.2.00.0080.00317.94
8.1.280.0120.00325.92
8.1.270.0080.00024.66
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.88
8.1.230.0110.00019.18
8.1.220.0060.00317.78
8.1.210.0040.00418.77
8.1.200.0060.00317.60
8.1.190.0040.00417.64
8.1.180.0040.00419.13
8.1.170.0050.00318.48
8.1.160.0000.00722.18
8.1.150.0000.00818.60
8.1.140.0070.00017.46
8.1.130.0000.00817.92
8.1.120.0000.00717.56
8.1.110.0040.00417.43
8.1.100.0000.00817.53
8.1.90.0000.00717.52
8.1.80.0040.00417.45
8.1.70.0030.00317.47
8.1.60.0040.00417.67
8.1.50.0000.00717.49
8.1.40.0000.00717.51
8.1.30.0000.00917.67
8.1.20.0050.00317.65
8.1.10.0000.00817.63
8.1.00.0000.00817.49
8.0.300.0040.00418.77
8.0.290.0070.00017.30
8.0.280.0000.00718.59
8.0.270.0030.00317.41
8.0.260.0040.00418.58
8.0.250.0000.00717.05
8.0.240.0000.00817.10
8.0.230.0000.00817.04
8.0.220.0040.00417.00
8.0.210.0070.00016.94
8.0.200.0000.00717.17
8.0.190.0000.00717.07
8.0.180.0030.00516.93
8.0.170.0000.00817.00
8.0.160.0050.00217.05
8.0.150.0000.00716.93
8.0.140.0000.00716.93
8.0.130.0000.00513.45
8.0.120.0020.00516.95
8.0.110.0000.00716.87
8.0.100.0040.00417.00
8.0.90.0000.00716.80
8.0.80.0090.00616.99
8.0.70.0000.00816.97
8.0.60.0000.00716.78
8.0.50.0040.00416.97
8.0.30.0090.01017.21
8.0.20.0110.00717.40
8.0.10.0020.00517.19
8.0.00.0130.00616.88
7.4.330.0000.00515.00
7.4.320.0000.00616.80
7.4.300.0030.00316.86
7.4.290.0000.00716.73
7.4.280.0000.00716.69
7.4.270.0080.00016.84
7.4.260.0030.00516.72
7.4.250.0050.00316.68
7.4.240.0020.00516.68
7.4.230.0070.00016.80
7.4.220.0030.01416.70
7.4.210.0100.00716.70
7.4.200.0000.00716.52
7.4.190.0070.00016.67
7.4.160.0060.01016.52
7.4.150.0170.00017.40
7.4.140.0110.00917.86
7.4.130.0100.00816.63
7.4.120.0140.00516.59
7.4.110.0140.01016.67
7.4.100.0130.01016.56
7.4.90.0040.01516.66
7.4.80.0090.01519.39
7.4.70.0110.00716.74
7.4.60.0130.01016.64
7.4.50.0030.00516.90
7.4.40.0150.00022.77
7.4.30.0110.00616.59
7.3.330.0050.00013.59
7.3.320.0030.00413.62
7.3.310.0070.00016.62
7.3.300.0030.00316.60
7.3.290.0040.01216.50
7.3.280.0080.00916.49
7.3.270.0100.00717.40
7.3.260.0090.00916.53
7.3.250.0130.00516.58
7.3.240.0100.00716.76
7.3.230.0070.01016.54
7.3.210.0090.00916.53
7.3.200.0090.00919.39
7.3.190.0140.00716.64
7.3.180.0030.01316.61
7.3.170.0060.00916.65
7.3.160.0120.00316.60
7.2.330.0030.01316.77
7.2.320.0090.00916.81
7.2.310.0060.01416.66
7.2.300.0160.00416.84
7.2.290.0080.00816.72
7.2.00.0000.01719.90
7.1.70.0000.00817.64
7.1.60.0140.01119.43
7.1.50.0000.01217.42
7.1.00.0070.06722.67
7.0.200.0050.00517.03
7.0.140.0070.07022.34
7.0.60.0070.08320.22
7.0.50.0030.06018.27
7.0.40.0100.08320.52
7.0.30.0470.06720.61
7.0.20.0230.07720.61
7.0.10.0070.04020.48
7.0.00.0070.04720.48
5.6.280.0000.07021.47
5.6.210.0100.08321.04
5.6.200.0100.07318.61
5.6.190.0070.05720.66
5.6.180.0030.05720.91
5.6.170.0300.07320.69
5.6.160.0300.06320.81
5.6.150.0100.04018.39
5.6.140.0070.06718.48
5.6.130.0000.09318.59
5.6.120.0200.07321.32
5.6.110.0030.08021.38
5.6.100.0070.04721.32
5.6.90.0030.04321.27
5.6.80.0070.07320.55
5.5.350.0030.07720.82
5.5.340.0030.07018.16
5.5.330.0130.07720.50
5.5.320.0130.07020.73
5.5.310.0230.04320.61
5.5.300.0070.08018.32
5.5.290.0000.05718.27
5.5.280.0030.05321.07
5.5.270.0070.05321.27
5.5.260.0100.06321.06
5.5.250.0070.07720.87
5.5.240.0330.06720.37
5.4.450.0370.04719.59
5.4.440.0230.04720.02
5.4.430.0570.03719.49
5.4.420.0130.05019.45
5.4.410.0100.06019.55
5.4.400.0030.07019.29
5.4.390.0100.06719.27
5.4.380.0100.05719.19
5.4.370.0030.06019.19
5.4.360.0170.04719.30
5.4.350.0080.04012.06
5.4.340.0100.03712.06
5.4.320.0060.04212.54
5.4.310.0050.04212.54
5.4.300.0070.03612.55
5.4.290.0070.03712.54
5.4.280.0070.03812.45
5.4.270.0080.03612.44
5.4.260.0040.03912.45
5.4.250.0120.04712.44
5.4.240.0070.05019.16
5.4.230.0000.06019.18
5.4.220.0130.04719.20
5.4.210.0030.05318.89
5.4.200.0170.04018.82
5.4.190.0070.05318.88
5.4.180.0130.04318.86
5.4.170.0030.05319.03
5.4.160.0100.04719.02
5.4.150.0200.04718.85
5.4.140.0030.05316.70
5.4.130.0070.04716.50
5.4.120.0100.04316.61
5.4.110.0070.04716.68
5.4.100.0100.04316.75
5.4.90.0030.05016.43
5.4.80.0070.04716.58
5.4.70.0030.05016.48
5.4.60.0100.04716.43
5.4.50.0070.04716.60
5.4.40.0100.04716.41
5.4.30.0030.05016.62
5.4.20.0070.04716.74
5.4.10.0030.05316.57
5.4.00.0130.04016.14
5.3.290.0040.04212.80
5.3.280.0030.05014.86
5.3.270.0070.05714.96
5.3.260.0000.05714.81
5.3.250.0200.05714.76
5.3.240.0200.05014.88
5.3.230.0100.04314.95
5.3.220.0100.04714.72
5.3.210.0070.05014.74
5.3.200.0100.04714.70
5.3.190.0030.05314.67
5.3.180.0100.04314.71
5.3.170.0130.04014.86
5.3.160.0070.05714.66
5.3.150.0100.04714.86
5.3.140.0000.05314.76
5.3.130.0070.05014.77
5.3.120.0100.06014.84
5.3.110.0130.04714.66
5.3.100.0100.04714.17
5.3.90.0000.05314.13
5.3.80.0170.03714.21
5.3.70.0070.04714.15
5.3.60.0070.04714.30
5.3.50.0070.04714.24
5.3.40.0030.05014.09
5.3.30.0030.06314.02
5.3.20.0100.04313.82
5.3.10.0070.04713.61
5.3.00.0100.04313.83
5.2.170.0000.05011.30
5.2.160.0100.03311.44
5.2.150.0070.04011.18
5.2.140.0130.03711.18
5.2.130.0030.04011.22
5.2.120.0100.03311.41
5.2.110.0100.03311.21
5.2.100.0070.03711.40
5.2.90.0130.04311.29
5.2.80.0030.04711.38
5.2.70.0030.04311.43
5.2.60.0030.04011.26
5.2.50.0070.04011.13
5.2.40.0100.03311.31
5.2.30.0070.04711.05
5.2.20.0070.03711.25
5.2.10.0000.04311.17
5.2.00.0000.04310.93
5.1.60.0030.03010.37
5.1.50.0100.03710.22
5.1.40.0030.04310.31
5.1.30.0070.03010.54
5.1.20.0030.03710.57
5.1.10.0030.03310.16
5.1.00.0030.03710.20
5.0.50.0030.0308.72
5.0.40.0030.0238.59
5.0.30.0030.0408.44
5.0.20.0000.0278.30
5.0.10.0000.0308.40
5.0.00.0000.0438.39
4.4.90.0000.0305.98
4.4.80.0030.0206.05
4.4.70.0000.0235.98
4.4.60.0000.0275.99
4.4.50.0000.0235.98
4.4.40.0030.0336.01
4.4.30.0030.0275.95
4.4.20.0070.0176.02
4.4.10.0030.0206.04
4.4.00.0030.0306.00
4.3.110.0000.0235.85
4.3.100.0000.0205.82
4.3.90.0070.0135.88
4.3.80.0030.0305.86
4.3.70.0070.0135.85
4.3.60.0000.0205.86
4.3.50.0000.0235.98
4.3.40.0000.0335.85
4.3.30.0000.0234.66
4.3.20.0070.0174.61
4.3.10.0000.0304.57
4.3.00.0000.01314.48

preferences:
36.85 ms | 401 KiB | 5 Q