3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roll($seed, $key, $nonce) { $key = "c52e2851529697f47fa4"; // excluding the dash and the nonce! $seed = "aa8efabd3f69a26e3f52dd9b28ecb7df68fbc5948d80b92725f23b1e4c6b3c23"; // bet made with seed pair (excluding current bet) $nonce = 0; $hash = hash_hmac('sha512', $key . '-' . $nonce, $seed); $index = 0; $lucky = hexdec(substr($hash, $index * 5, 5)); while ($lucky >= pow(10, 6)) { $index++; $lucky = hexdec(substr($hash, $index * 5, 5)); if ($index * 5 + 5 > 128) { return '99.99'; break; } } $lucky %= pow(10, 4); $lucky = sprintf('%.2f', bcdiv($lucky, '100', 2)); return $lucky; } echo roll('bla','blah',2); ?> <?php function roll($seed, $key, $nonce) { $key = "c52e2851529697f47fa4"; // excluding the dash and the nonce! $seed = "aa8efabd3f69a26e3f52dd9b28ecb7df68fbc5948d80b92725f23b1e4c6b3c23"; // bet made with seed pair (excluding current bet) $nonce = 0; $hash = hash_hmac('sha512', $key . '-' . $nonce, $seed); $index = 0; $lucky = hexdec(substr($hash, $index * 5, 5)); while ($lucky >= pow(10, 6)) { $index++; $lucky = hexdec(substr($hash, $index * 5, 5)); if ($index * 5 + 5 > 128) { return '99.99'; break; } } $lucky %= pow(10, 4); $lucky = sprintf('%.2f', bcdiv($lucky, '100', 2)); return $lucky; } echo roll('bla','blah',2); echo $hash; ?> <?php echo hash('sha512', '3d7ff67a23443ccfc42c065ab588700d886b310c805fc850b97c39d112ec9a6e'); ?>

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.1.40.3630.06338.38
7.1.30.4630.01732.65
7.1.20.2400.01332.48
7.1.10.4600.00714.30
7.1.00.2900.01014.54
7.0.180.0300.06020.05
7.0.170.3000.01013.95
7.0.160.2370.01014.07
7.0.150.3730.01314.20
7.0.140.5000.00714.11
7.0.130.3170.01714.34
7.0.120.2630.01314.18
7.0.110.4900.01314.39
7.0.100.3530.02314.34
7.0.90.0200.01714.18
7.0.80.3970.00714.27
7.0.70.0630.03517.05
7.0.60.3070.03016.88
7.0.50.2100.03217.28
7.0.40.1700.03717.33
7.0.30.2620.04217.31
7.0.20.3420.03517.32
7.0.10.2120.03317.45
7.0.00.2520.03217.40
5.6.300.0100.06320.73
5.6.290.0170.06320.72
5.6.280.0100.05720.90
5.6.270.0070.07020.65
5.6.260.0200.06320.64
5.6.250.0230.06020.90
5.6.240.0030.09320.58
5.6.230.0230.05320.83
5.6.220.0520.06720.61
5.6.210.0570.05820.68
5.6.200.0680.05520.85
5.6.190.0730.05321.02
5.6.180.0630.05720.83
5.6.170.0830.05520.88
5.6.160.0680.06320.98
5.6.150.0820.05720.88
5.6.140.0730.04820.94
5.6.130.0770.06020.91
5.6.120.0180.05820.90
5.6.110.0370.06020.87
5.6.100.0750.06020.83
5.6.90.0850.07320.81
5.6.80.0720.05820.20
5.6.70.0750.06020.35
5.6.60.0680.06020.26
5.6.50.0870.05520.29
5.6.40.0830.06220.22
5.6.30.0830.05520.25
5.6.20.0850.06320.28
5.6.10.0870.05520.13
5.6.00.0900.05520.15
5.5.380.0100.07317.36
5.5.370.0130.06017.32
5.5.360.0630.06718.91
5.5.350.0700.05318.91
5.5.340.0670.05719.45
5.5.330.0720.05319.44
5.5.320.0580.06219.35
5.5.310.0770.05319.33
5.5.300.0730.05519.37
5.5.290.0680.06519.41
5.5.280.0170.05819.19
5.5.270.0770.07019.49
5.5.260.0780.06819.15
5.5.250.0900.05019.15
5.5.240.0920.07518.79
5.5.230.0700.06218.64
5.5.220.0830.05518.79
5.5.210.0750.05818.77
5.5.200.0720.05518.73
5.5.190.0820.05818.72
5.5.180.0800.06518.89
5.5.160.0830.05518.81
5.5.150.0620.05818.71
5.5.140.0750.05018.73
5.5.130.0750.05318.59
5.5.120.0880.06018.77
5.5.110.0780.05518.77
5.5.100.0670.05718.69
5.5.90.0730.05518.67
5.5.80.0820.05318.53
5.5.70.0770.05318.51
5.5.60.0880.05718.55
5.5.50.0800.04818.54
5.5.40.0820.05218.49
5.5.30.0950.05518.58
5.5.20.0880.06018.59
5.5.10.0800.05718.64
5.5.00.0830.06218.65

preferences:
146.5 ms | 1394 KiB | 7 Q