3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shitty_prng($bytes = 32) { $buf = ''; for ($i = 0; $i < $bytes; ++$i) { $buf .= chr(mt_rand(0, 255)); } } function better_prng($bytes = 32) { return random_bytes($bytes); } function openssl_prng($bytes = 32) { return openssl_random_pseudo_bytes($bytes); } function mcrypt_prng($bytes = 32) { return mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM); } $buf = ''; $tests = []; $start = microtime(true); for ($i = 0; $i < 100000; ++$i) { $buf = shitty_prng(); } $tests['mtrand'] = ( microtime(true) - $start ); $start = microtime(true); for ($i = 0; $i < 100000; ++$i) { $buf = better_prng(); } $tests['csprng'] = ( microtime(true) - $start ); $start = microtime(true); for ($i = 0; $i < 100000; ++$i) { $buf = openssl_prng(); } $tests['openssl'] = ( microtime(true) - $start ); $start = microtime(true); for ($i = 0; $i < 100000; ++$i) { $buf = mcrypt_prng(); } $tests['mcrypt'] = ( microtime(true) - $start ); var_dump($tests);

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)
7.3.10.1170.39416.78
7.3.00.0800.44916.48
7.2.130.0870.42516.57
7.2.120.0830.43216.65
7.2.110.0870.39016.60
7.2.100.0800.41916.92
7.2.90.0870.40816.81
7.2.80.0740.46216.82
7.2.70.0760.46816.85
7.2.60.0960.43516.96
7.2.50.0940.41417.01
7.2.40.0830.38716.82
7.2.30.0770.41317.03
7.2.20.0900.42416.87
7.2.10.1190.44716.89
7.2.00.0860.42816.96
7.1.250.1070.74715.97
7.1.240.0860.71915.77
7.1.230.0970.69715.61
7.1.220.0930.69915.57
7.1.210.0930.66815.73
7.1.200.0730.73215.90
7.1.190.0860.70815.58
7.1.180.1060.70915.84
7.1.170.0830.73315.87
7.1.160.0900.72715.86
7.1.150.0770.73915.54
7.1.140.1060.71415.63
7.1.130.1230.73815.86
7.1.120.0730.69115.54
7.1.110.0900.68915.93
7.1.100.0830.70815.75
7.1.90.0760.71515.80
7.1.80.0730.74615.42
7.1.70.0580.66816.48
7.1.60.0780.69617.68
7.1.50.0820.63616.30
7.1.40.0860.71515.70
7.1.30.0970.74015.83
7.1.20.0800.73915.86
7.1.10.0730.72315.75
7.1.00.0630.70719.02
7.0.330.1160.72515.13
7.0.320.0730.74015.26
7.0.310.0870.72415.37
7.0.300.0830.68415.44
7.0.290.0930.66315.60
7.0.280.0630.72215.18
7.0.270.1130.68915.26
7.0.260.0940.65815.29
7.0.250.0670.68215.39
7.0.240.0670.71215.24
7.0.230.0800.71015.46
7.0.220.0830.67915.37
7.0.210.0860.69315.45
7.0.200.1110.68716.17
7.0.190.0730.74615.42
7.0.180.0630.73815.41
7.0.170.0870.69315.41
7.0.160.1200.69015.10
7.0.150.0930.71515.20
7.0.140.0800.68715.46
7.0.130.0630.67415.54
7.0.120.0630.68415.41
7.0.110.0700.67615.24
7.0.100.0770.67515.47
7.0.90.0800.69415.25
7.0.80.0800.67415.21
7.0.70.0700.65915.35
7.0.60.2420.62017.62
7.0.50.3950.61016.66
7.0.40.4120.62016.85
7.0.30.4180.60416.89
7.0.20.4400.62916.83
7.0.10.4280.61616.87
7.0.00.4070.56916.85
5.6.380.0101.32314.05
5.6.370.0001.37614.44
5.6.360.0101.27214.58
5.6.350.0101.33414.58
5.6.340.0101.28414.62
5.6.330.0031.29714.31
5.6.320.0031.26114.59
5.6.310.0001.30014.80
5.6.300.0201.23014.54
5.6.290.0071.20714.36
5.6.280.0071.27417.63
5.6.270.0031.25714.38
5.6.260.0101.23914.45
5.6.250.0031.24814.29
5.6.240.0001.25214.17
5.6.230.0131.18014.49
5.6.220.0361.21714.26
5.6.210.0051.02317.53
5.6.200.0051.00816.24
5.6.190.0051.01717.31
5.6.180.0250.99617.49
5.6.170.0150.99017.59
5.6.160.0151.00817.53
5.6.150.0101.02416.25
5.6.140.0050.95916.23
5.6.130.0121.00616.33
5.6.120.0131.00817.77
5.6.110.0031.03917.72
5.6.100.0080.99417.71
5.6.90.0120.96517.73
5.6.80.0100.98517.34
5.6.70.0131.26814.21
5.6.60.0031.25914.16
5.6.50.0201.24014.03
5.6.40.0131.28414.35
5.6.30.0031.31814.11
5.6.20.0101.29114.00
5.6.10.0031.28914.25
5.6.00.0071.24914.13
5.5.380.0001.28511.11
5.5.370.0101.26311.21
5.5.360.0071.23411.09
5.5.350.0151.21015.81
5.5.340.0081.01314.52
5.5.330.0081.02715.70
5.5.320.0031.03115.76
5.5.310.0200.99715.71
5.5.300.0021.16214.76
5.5.290.0071.05214.59
5.5.280.0080.98715.84
5.5.270.0101.01115.85
5.5.260.0101.04116.04
5.5.250.0081.04615.88
5.5.240.0101.00115.77
5.5.230.0031.28910.89
5.5.220.0101.29011.00
5.5.210.0101.36511.22
5.5.200.0071.31711.34
5.5.190.0101.28810.92
5.5.180.0031.31511.13
5.5.170.0071.29510.82
5.5.160.0031.25910.72
5.5.150.0001.28510.80
5.5.140.0031.26210.67
5.5.130.0161.32010.91
5.5.120.0101.31711.10
5.5.110.0031.35510.80
5.5.100.0071.31010.69
5.5.90.0071.33910.58
5.5.80.0171.34611.27
5.5.70.0261.28510.78
5.5.60.0031.26610.70
5.5.50.0001.25610.75
5.5.40.0031.26111.09
5.5.30.0071.23510.95
5.5.20.0001.36511.12
5.5.10.0031.33011.23
5.5.00.0031.26511.20
5.4.450.0151.34915.10
5.4.440.0231.40815.37
5.4.430.0251.38415.23
5.4.420.0151.42115.06
5.4.410.0351.44915.35
5.4.400.0251.52515.16
5.4.390.0271.47715.04
5.4.380.0181.45214.99
5.4.370.0231.43114.95
5.4.360.0231.51314.86
5.4.350.0321.52414.91
5.4.340.0271.46315.01
5.4.330.0031.35810.52
5.4.320.0271.38814.98
5.4.310.0381.45714.98
5.4.300.0421.41114.92
5.4.290.0401.39515.01
5.4.280.0201.36715.09
5.4.270.0231.39515.00
5.4.260.0231.43015.07
5.4.250.0171.47514.81
5.4.240.0351.45915.17
5.4.230.0251.43815.01
5.4.220.0201.46615.17
5.4.210.0201.45214.94
5.4.200.0301.42013.72
5.4.190.0271.36015.01
5.4.180.0331.40815.09
5.4.170.0231.47915.21
5.4.160.0251.43114.89
5.4.150.0321.40515.06
5.4.140.0221.40813.86
5.4.130.0121.33514.06
5.4.120.0271.29513.89
5.4.110.0231.29813.93
5.4.100.0271.36513.69
5.4.90.0351.30413.69
5.4.80.0221.33513.90
5.4.70.0121.29713.75
5.4.60.0301.29813.66
5.4.50.0131.30813.60
5.4.40.0201.32413.89
5.4.30.0121.31313.88
5.4.20.0251.44013.65
5.4.10.0171.33913.66
5.4.00.0151.35713.48
5.3.290.0170.03512.38
5.3.280.0130.02712.27
5.3.270.0080.03312.54
5.3.260.0150.04012.42
5.3.250.0170.03512.40
5.3.240.0150.03012.41
5.3.230.0190.02312.48
5.3.220.0150.04212.42
5.3.210.0070.03412.38
5.3.200.0190.02312.34
5.3.190.0130.02712.36
5.3.180.0150.02812.47
5.3.170.0130.02712.54
5.3.160.0190.02412.31
5.3.150.0100.04312.45
5.3.140.0120.02712.46
5.3.130.0090.03012.44
5.3.120.0120.03512.46
5.3.110.0210.02512.40
5.3.100.0140.02512.30
5.3.90.0080.03212.23
5.3.80.0130.02512.19
5.3.70.0110.02712.22
5.3.60.0130.02612.11
5.3.50.0110.03612.11
5.3.40.0130.02812.12
5.3.30.0090.03312.04
5.3.20.0220.02511.98
5.3.10.0190.01911.76
5.3.00.0140.02611.81
5.2.170.0090.03210.15
5.2.160.0120.02410.31
5.2.150.0160.02010.21
5.2.140.0120.02610.25
5.2.130.0100.02210.16
5.2.120.0130.02310.26
5.2.110.0120.02210.25
5.2.100.0100.02310.29
5.2.90.0140.02810.24
5.2.80.0150.02010.18
5.2.70.0140.02610.22
5.2.60.0160.02710.15
5.2.50.0080.03010.15
5.2.40.0090.02410.17
5.2.30.0100.02810.15
5.2.20.0100.02310.13
5.2.10.0070.02310.10
5.2.00.0080.02810.00
5.1.60.0080.0209.69
5.1.50.0090.0199.60
5.1.40.0100.0229.57
5.1.30.0080.0239.89
5.1.20.0070.0269.83
5.1.10.0110.0209.62
5.1.00.0070.0229.70
5.0.50.0050.0168.99
5.0.40.0060.0158.78
5.0.30.0040.0258.79
5.0.20.0060.0158.74
5.0.10.0050.0178.77
5.0.00.0060.0208.67
4.4.90.0070.0187.53
4.4.80.0030.0207.55
4.4.70.0100.0097.50
4.4.60.0030.0177.59
4.4.50.0060.0127.59
4.4.40.0030.0227.59
4.4.30.0030.0157.56
4.4.20.0050.0127.55
4.4.10.0050.0117.54
4.4.00.0130.0107.61
4.3.110.0070.0107.54
4.3.100.0090.0107.55
4.3.90.0040.0127.52
4.3.80.0000.0227.47
4.3.70.0090.0077.52
4.3.60.0070.0107.54
4.3.50.0050.0127.46
4.3.40.0030.0187.49
4.3.30.0020.0156.90
4.3.20.0000.0156.84
4.3.10.0040.0106.88
4.3.00.0020.0148.31

preferences:
25.25 ms | 401 KiB | 5 Q