3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Generate a random string, using a cryptographically secure * pseudorandom number generator (random_int) * * For PHP 7, random_int is a PHP core function * For PHP 5.x, depends on https://github.com/paragonie/random_compat * * @param int $length How many characters do we want? * @param string $keyspace A string of all possible characters * to select from * @return string */ function random_str( int $length = 64, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ): string { if ($length < 1) { throw new \RangeException("Length must be a positive integer"); } $pieces = []; $max = mb_strlen($keyspace, '8bit') - 1; for ($i = 0; $i < $length; ++$i) { $pieces []= $keyspace[random_int(0, $max)]; } return implode('', $pieces); } $a = random_str(32); $b = random_str(8, 'abcdefghijklmnopqrstuvwxyz'); $c = random_str(); var_dump($a, $b, $c);

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.4.10.0210.00918.56
8.3.140.0270.00716.48
8.3.130.0270.01116.30
8.3.120.0330.00816.43
8.3.110.0380.00316.55
8.3.100.0310.01026.90
8.3.90.0190.00822.91
8.3.80.0250.00718.59
8.3.70.0330.00718.58
8.3.60.0270.01222.31
8.3.50.0390.00819.77
8.3.40.0330.01020.52
8.3.30.0250.00820.46
8.3.20.0270.00620.64
8.3.10.0240.00920.61
8.3.00.0150.00720.55
8.2.260.0320.00816.42
8.2.250.0320.00916.60
8.2.240.0320.00516.37
8.2.230.0250.00516.58
8.2.220.0300.00716.41
8.2.210.0260.00819.77
8.2.200.0260.00719.89
8.2.190.0260.00519.82
8.2.180.0270.00619.80
8.2.170.0200.01019.84
8.2.160.0280.00721.53
8.2.150.0170.00820.73
8.2.140.0220.00722.21
8.2.130.0160.00826.01
8.2.120.0250.01020.66
8.2.110.0160.00821.13
8.2.100.0200.00519.26
8.2.90.0290.00720.58
8.2.80.0260.01020.56
8.2.70.0110.00460.62
8.2.60.0210.00629.45
8.2.50.0140.00825.09
8.2.40.0150.00524.18
8.2.30.0130.00422.35
8.2.20.0100.00623.20
8.2.10.0080.00620.07
8.2.00.0120.00621.59
8.1.310.0170.00616.28
8.1.300.0240.00815.88
8.1.290.0220.00519.63
8.1.280.0270.00719.73
8.1.270.0310.00720.39
8.1.260.0340.00920.26
8.1.250.0340.00120.40
8.1.240.0190.01219.51
8.1.230.0230.00720.33
8.1.220.0240.00219.52
8.1.210.0220.01220.37
8.1.200.0190.00726.74
8.1.190.0170.00629.56
8.1.180.0170.00326.18
8.1.170.0160.00525.37
8.1.160.0160.00624.54
8.1.150.0150.00724.50
8.1.140.0100.00420.86
8.1.130.0130.00721.78
8.1.120.0130.00521.11
8.1.110.0120.00620.50
8.1.100.0110.00619.74
8.1.90.0120.00519.76
8.1.80.0120.00619.70
8.1.70.0090.00518.75
8.1.60.0120.00519.12
8.1.50.0130.00619.21
8.1.40.0130.00619.24
8.1.30.0140.00519.10
8.1.20.0140.00518.85
8.1.10.0130.00518.63
8.1.00.0150.00518.77
8.0.300.0270.00624.32
8.0.290.0200.00429.28
8.0.280.0150.00524.48
8.0.270.0140.00622.81
8.0.260.0140.00521.58
8.0.250.0140.00520.67
8.0.240.0120.00420.38
8.0.230.0090.00719.48
8.0.220.0120.00519.50
8.0.210.0110.00519.24
8.0.200.0110.00519.10
8.0.190.0120.00518.93
8.0.180.0120.00518.76
8.0.170.0100.00618.77
8.0.160.0110.00518.37
8.0.150.0130.00518.24
8.0.140.0130.00518.10
8.0.130.0130.00518.15
8.0.120.0110.00517.22
8.0.110.0110.00517.86
8.0.100.0110.00517.84
8.0.90.0110.00517.80
8.0.80.0110.00617.63
8.0.70.0110.00617.71
8.0.60.0110.00617.74
8.0.50.0110.00517.75
8.0.30.0110.00617.45
8.0.20.0120.00617.54
8.0.10.0110.00717.51
8.0.00.0110.00617.51
7.4.330.0110.00419.93
7.4.320.0140.00419.78
7.4.300.0110.00418.45
7.4.290.0110.00418.10
7.4.280.0110.00517.78
7.4.270.0110.00517.56
7.4.260.0120.00517.73
7.4.250.0120.00517.28
7.4.240.0110.00517.55
7.4.230.0110.00517.49
7.4.220.0090.00517.40
7.4.210.0090.00517.39
7.4.200.0100.00517.43
7.4.190.0090.00517.52
7.4.180.0090.00617.51
7.4.160.0100.00617.25
7.4.150.0100.00617.16
7.4.140.0100.00617.17
7.4.130.0100.00717.11
7.4.120.0110.00617.11
7.4.110.0110.00717.01
7.4.100.0100.00717.05
7.4.90.0100.00716.99
7.4.80.0110.00716.94
7.4.70.0100.00716.93
7.4.60.0110.00716.90
7.4.50.0100.00816.79
7.4.40.0110.00716.79
7.4.30.0100.00716.81
7.4.20.0100.00716.76
7.4.10.0100.00816.75
7.4.00.0090.00716.73
7.3.330.0120.00417.53
7.3.320.0120.00517.42
7.3.310.0130.00517.51
7.3.300.0130.00417.42
7.3.290.0110.00517.13
7.3.280.0110.00617.14
7.3.270.0110.00616.96
7.3.260.0120.00616.96
7.3.250.0120.00616.92
7.3.240.0120.00716.92
7.3.230.0110.00716.88
7.3.220.0120.00716.84
7.3.210.0120.00716.84
7.3.200.0120.00716.80
7.3.190.0110.00716.79
7.3.180.0110.00716.78
7.3.170.0120.00716.75
7.3.160.0120.00716.76
7.3.150.0120.00716.73
7.3.140.0120.00716.72
7.3.130.0110.00716.69
7.3.120.0110.00716.58
7.3.110.0110.00816.50
7.3.100.0110.00716.33
7.3.90.0110.00816.38
7.3.80.0120.00716.27
7.3.70.0110.00716.29
7.3.60.0100.00816.32
7.3.50.0110.00716.30
7.3.40.0110.00716.31
7.3.30.0110.00816.30
7.3.20.0130.00816.79
7.3.10.0140.00716.74
7.3.00.0130.00816.75
7.2.340.0160.00716.98
7.2.330.0150.00716.91
7.2.320.0160.00716.91
7.2.310.0150.00716.84
7.2.300.0150.00816.87
7.2.290.0140.00816.83
7.2.280.0140.00816.82
7.2.270.0140.00816.79
7.2.260.0140.00816.78
7.2.250.0130.00816.74
7.2.240.0130.00816.66
7.2.230.0130.00816.52
7.2.220.0130.00816.43
7.2.210.0140.00816.40
7.2.200.0130.00816.45
7.2.190.0130.00816.41
7.2.180.0130.00816.41
7.2.170.0120.00816.44
7.2.160.0120.00816.43
7.2.150.0140.00916.95
7.2.140.0140.00816.95
7.2.130.0140.00817.03
7.2.120.0140.00816.98
7.2.110.0140.00816.98
7.2.100.0150.00816.98
7.2.90.0150.00816.95
7.2.80.0140.00816.95
7.2.70.0140.00916.96
7.2.60.0140.00816.96
7.2.50.0150.00816.96
7.2.40.0150.00816.98
7.2.30.0140.00816.99
7.2.20.0150.00916.97
7.2.10.0150.00816.97
7.2.00.0150.00817.00
7.1.330.0170.00816.29
7.1.320.0160.00816.05
7.1.310.0160.00816.02
7.1.300.0160.00815.98
7.1.290.0160.00815.97
7.1.280.0170.00815.98
7.1.270.0150.00715.97
7.1.260.0150.00815.96
7.1.250.0160.00815.94
7.1.240.0180.00816.41
7.1.230.0180.00716.41
7.1.220.0170.00716.43
7.1.210.0170.00716.43
7.1.200.0170.00716.43
7.1.190.0160.00816.44
7.1.180.0170.00716.38
7.1.170.0170.00716.39
7.1.160.0170.00716.38
7.1.150.0170.00716.38
7.1.140.0170.00816.40
7.1.130.0170.00716.39
7.1.120.0180.00816.37
7.1.110.0180.00716.50
7.1.100.0170.00716.42
7.1.90.0170.00716.40
7.1.80.0160.00816.43
7.1.70.0170.00716.33
7.1.60.0160.00716.43
7.1.50.0160.00816.44
7.1.40.0170.00716.44
7.1.30.0170.00716.45
7.1.20.0160.00816.42
7.1.10.0160.00816.41
7.1.00.0170.00716.41

preferences:
33.7 ms | 403 KiB | 5 Q