3v4l.org

run code in 300+ PHP versions simultaneously
<?php // // // EmpireDrop Provably Fair Case Battles // // // /* * Fill in all three below and click the blue 'eval();' button. ------------------ */ $server_seed = ''; $client_seed = ''; $nonce = $roundNumber = 0; /* ------------------ */ if ($server_seed == '' || $client_seed == '' || $nonce < 0) { echo "Fill in details"; return; } define('MIN_RESULT', 0.00001); define('MAX_RESULT', 100); define('CONVERT_RATE', 100000); define('HASH_TYPE', 'sha256'); function getProvablyFairResult(string $client_seed, string $server_seed, int $nounce) { $hash = hash_hmac(HASH_TYPE, "{$client_seed}-{$nounce}", $server_seed); $normalized = hexdec($hash) / (16 ** strlen($hash)); $roll = MIN_RESULT + $normalized * (MAX_RESULT - MIN_RESULT); return convertDecimalValue($roll); } function convertDecimalValue(float $value): int { return round($value * CONVERT_RATE); } $result = getProvablyFairResult($client_seed, $server_seed, $nonce); echo "Result: {$result}";

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.110.0050.00320.94
8.3.100.0060.00324.06
8.3.90.0300.00824.21
8.3.80.0340.00624.72
8.3.70.0330.01223.84
8.3.60.0350.01023.70
8.3.50.0210.00923.75
8.3.40.0270.00623.97
8.3.30.0300.00623.97
8.3.20.0260.00923.95
8.3.10.0300.00723.93
8.3.00.0270.00623.96
8.2.230.0030.00622.58
8.2.220.0120.00637.54
8.2.210.0220.00524.17
8.2.200.0190.00724.76
8.2.190.0280.00623.64
8.2.180.0230.00723.68
8.2.170.0210.00624.05
8.2.160.0280.00424.00
8.2.150.0250.00623.97
8.2.140.0260.00823.99
8.2.130.0280.00723.99
8.2.120.0300.00424.00
8.2.110.0280.00623.99
8.2.100.0280.00723.99
8.2.90.0280.00623.99
8.2.80.0280.00523.95
8.2.70.0310.00624.00
8.2.60.0280.00923.97
8.2.50.0320.00623.95
8.2.40.0260.01023.93
8.2.30.0240.00824.01
8.2.20.0260.00623.97
8.2.10.0230.00623.99
8.2.00.0270.00624.01
8.1.290.0260.00624.97
8.1.280.0290.00523.65
8.1.270.0300.00423.93
8.1.260.0260.00723.95
8.1.250.0260.00823.95
8.1.240.0230.00623.93
8.1.230.0240.00523.97
8.1.220.0220.00623.97
8.1.210.0210.00523.91
8.1.200.0220.00523.93
8.1.190.0230.00524.14
8.1.180.0240.00423.84
8.1.170.0230.00624.18
8.1.160.0190.00824.18
8.1.150.0190.00724.19
8.1.140.0230.00723.84
8.1.130.0270.00623.91
8.1.120.0220.00623.93
8.1.110.0220.00723.91
8.1.100.0260.00523.91
8.1.90.0250.00423.89
8.1.80.0210.00823.93
8.1.70.0250.00423.92
8.1.60.0250.00624.16
8.1.50.0280.00323.93
8.1.40.0250.00724.00
8.1.30.0240.00823.95
8.1.20.0290.00523.95
8.1.10.0290.00824.20
8.1.00.0240.00823.90

preferences:
25.67 ms | 403 KiB | 5 Q