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.3.60.0190.00925.92
8.2.170.0120.01018.85
8.2.160.0200.00922.96
8.2.150.0150.00820.80
8.2.140.0110.00824.66
8.2.130.0110.00828.09
8.2.110.0130.00721.31
8.2.100.0170.00318.59
8.2.70.0070.00469.88
8.2.60.0110.00538.36
8.2.50.0090.00826.83
8.2.40.0110.00325.39
8.2.30.0090.00522.74
8.2.20.0080.00523.89
8.2.10.0070.00620.02
8.2.00.0090.00621.77
8.1.240.0140.01418.92
8.1.220.0160.00318.13
8.1.200.0120.00830.60
8.1.190.0130.00138.83
8.1.180.0120.00229.14
8.1.170.0120.00427.51
8.1.160.0120.00526.10
8.1.150.0110.00726.06
8.1.140.0080.00420.93
8.1.130.0110.00622.07
8.1.120.0110.00521.22
8.1.110.0090.00620.52
8.1.100.0090.00619.69
8.1.90.0110.00419.71
8.1.80.0110.00519.64
8.1.70.0080.00518.68
8.1.60.0110.00519.04
8.1.50.0120.00619.13
8.1.40.0120.00519.17
8.1.30.0130.00519.02
8.1.20.0130.00518.78
8.1.10.0130.00518.56
8.1.00.0140.00518.74
8.0.290.0100.00338.63
8.0.280.0110.00426.19
8.0.270.0110.00623.58
8.0.260.0110.00421.92
8.0.250.0110.00420.76
8.0.240.0110.00420.43
8.0.230.0080.00619.43
8.0.220.0110.00519.47
8.0.210.0090.00519.18
8.0.200.0100.00519.03
8.0.190.0100.00518.86
8.0.180.0110.00518.68
8.0.170.0090.00618.69
8.0.160.0110.00518.29
8.0.150.0120.00518.16
8.0.140.0120.00518.02
8.0.130.0120.00518.07
8.0.120.0110.00517.12
8.0.110.0110.00517.79
8.0.100.0110.00517.76
8.0.90.0100.00517.73
8.0.80.0110.00617.57
8.0.70.0100.00617.64
8.0.60.0100.00617.67
8.0.50.0100.00517.68
8.0.30.0110.00617.40
8.0.20.0120.00617.49
8.0.10.0110.00717.45
8.0.00.0100.00617.46
7.4.330.0090.00319.95
7.4.320.0140.00319.79
7.4.300.0100.00418.37
7.4.290.0100.00418.02
7.4.280.0100.00517.70
7.4.270.0100.00517.49
7.4.260.0120.00517.65
7.4.250.0110.00517.19
7.4.240.0100.00417.46
7.4.230.0100.00517.42
7.4.220.0090.00417.33
7.4.210.0090.00517.32
7.4.200.0090.00517.35
7.4.190.0090.00517.45
7.4.180.0090.00617.43
7.4.160.0100.00617.19
7.4.150.0100.00617.11
7.4.140.0100.00617.11
7.4.130.0100.00717.06
7.4.120.0110.00717.05
7.4.110.0110.00716.96
7.4.100.0100.00717.00
7.4.90.0100.00716.95
7.4.80.0110.00716.89
7.4.70.0100.00716.89
7.4.60.0110.00716.86
7.4.50.0100.00816.75
7.4.40.0100.00716.75
7.4.30.0100.00716.77
7.4.20.0100.00716.73
7.4.10.0100.00716.71
7.4.00.0090.00716.70
7.3.330.0120.00417.45
7.3.320.0120.00517.32
7.3.310.0120.00517.42
7.3.300.0120.00417.34
7.3.290.0100.00517.06
7.3.280.0110.00617.07
7.3.270.0110.00616.90
7.3.260.0120.00616.90
7.3.250.0110.00616.87
7.3.240.0120.00716.87
7.3.230.0110.00716.83
7.3.220.0120.00716.79
7.3.210.0110.00716.79
7.3.200.0120.00716.76
7.3.190.0110.00716.75
7.3.180.0110.00716.74
7.3.170.0120.00716.71
7.3.160.0110.00716.72
7.3.150.0110.00716.70
7.3.140.0120.00716.68
7.3.130.0110.00716.65
7.3.120.0110.00716.54
7.3.110.0110.00816.47
7.3.100.0110.00716.29
7.3.90.0110.00816.34
7.3.80.0120.00716.24
7.3.70.0110.00716.25
7.3.60.0100.00816.29
7.3.50.0110.00716.27
7.3.40.0110.00716.27
7.3.30.0100.00816.27
7.3.20.0130.00816.75
7.3.10.0130.00716.70
7.3.00.0130.00816.71
7.2.340.0160.00716.93
7.2.330.0150.00716.87
7.2.320.0160.00716.86
7.2.310.0150.00716.80
7.2.300.0140.00816.83
7.2.290.0140.00816.79
7.2.280.0140.00816.78
7.2.270.0140.00816.76
7.2.260.0140.00816.74
7.2.250.0130.00816.71
7.2.240.0130.00816.62
7.2.230.0130.00816.49
7.2.220.0130.00816.40
7.2.210.0130.00816.37
7.2.200.0130.00816.42
7.2.190.0130.00816.38
7.2.180.0130.00816.38
7.2.170.0120.00816.41
7.2.160.0120.00816.40
7.2.150.0140.00916.92
7.2.140.0140.00816.91
7.2.130.0140.00816.99
7.2.120.0140.00816.94
7.2.110.0140.00816.94
7.2.100.0150.00816.94
7.2.90.0150.00816.91
7.2.80.0140.00816.92
7.2.70.0140.00916.92
7.2.60.0140.00816.92
7.2.50.0150.00816.92
7.2.40.0150.00816.95
7.2.30.0140.00816.95
7.2.20.0150.00916.93
7.2.10.0150.00816.93
7.2.00.0150.00816.96
7.1.330.0170.00816.24
7.1.320.0160.00816.01
7.1.310.0160.00815.98
7.1.300.0160.00815.94
7.1.290.0160.00815.93
7.1.280.0170.00815.94
7.1.270.0150.00715.93
7.1.260.0150.00815.92
7.1.250.0160.00815.90
7.1.240.0180.00816.36
7.1.230.0180.00716.37
7.1.220.0170.00716.38
7.1.210.0170.00716.38
7.1.200.0160.00716.38
7.1.190.0160.00816.39
7.1.180.0170.00716.34
7.1.170.0170.00716.34
7.1.160.0170.00816.33
7.1.150.0170.00816.33
7.1.140.0170.00816.35
7.1.130.0170.00716.34
7.1.120.0180.00816.32
7.1.110.0170.00716.37
7.1.100.0170.00716.37
7.1.90.0170.00716.35
7.1.80.0160.00816.38
7.1.70.0170.00716.28
7.1.60.0160.00716.38
7.1.50.0160.00816.39
7.1.40.0160.00716.40
7.1.30.0170.00716.40
7.1.20.0160.00816.38
7.1.10.0160.00816.36
7.1.00.0170.00716.36
5.6.400.0280.00325.92
5.5.90.0150.00828.09
5.3.290.0100.00216.80

preferences:
60.16 ms | 401 KiB | 5 Q