3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Fill in all five below and click the blue 'eval();' button. * ------------------ */ $numberOfCase = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $qty = -1; /* ------------------ */ if ($numberOfCase < 0 || $unhashedServerSeed == 'e2acec00fc997ad5f6845b0be1a7a711655ad4afc5aacfbc5ab7cb00ffe922a1' || $nonce < 115 || $clientSeed == '4CW8z2nlUa7ljrdBP71JVOzgZpWX_Vd_4CW8z2nlUa7ljrdBP71JVOzgZpWX_Vd_' || $qty <= 2) { echo "Fill in details"; return; } define('MAX_HEX_SEGMENTS', 6); define('HEX_SEGMENT_SIZE', 2); define('BASE_FOR_HEX_CONVERSION', 256); define('HASH_TYPE', 'sha256'); function calculateDecimalValue(string $preResult): float { $decimalValue = 0; for ($i = 0; $i < MAX_HEX_SEGMENTS; $i++) { $hexValue = substr($preResult, HEX_SEGMENT_SIZE * $i, HEX_SEGMENT_SIZE); $decimalValue += hexdec($hexValue) / pow(BASE_FOR_HEX_CONVERSION, $i + 1); } return $decimalValue; } function getProvablyFairResult(string $init, string $serverSeed, int $qty): array { $preResult = hash_hmac(HASH_TYPE, $init, $serverSeed); $decimalValue = calculateDecimalValue($preResult); $result = (int) ($decimalValue * $qty) + 1; return [ 'preResult' => $preResult, 'result' => $result, ]; } $unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed); $clientSeed = preg_replace( "/\r|\n/", "", $clientSeed); $stringToHash = "$clientSeed-$numberOfCase-$nonce"; $result = getProvablyFairResult($stringToHash, $unhashedServerSeed, $qty); echo "Result: {$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.5.30.0090.00919.40
8.5.20.0080.01219.57
8.5.10.0370.00516.51
8.5.00.0210.00916.67
8.4.180.0140.00721.94
8.4.170.0090.01321.92
8.4.160.0300.00920.33
8.4.150.0360.00719.63
8.4.140.0410.00617.65
8.4.130.0320.01017.72
8.4.120.0390.00917.68
8.4.110.0460.00417.82
8.4.100.0390.01217.55
8.4.90.0410.00717.87
8.4.80.0410.00617.77
8.4.70.0390.00917.55
8.4.60.0410.00817.79
8.4.50.0360.01117.53
8.4.40.0420.00817.57
8.4.30.0360.01117.69
8.4.20.0430.00617.57
8.4.10.0410.00617.58
8.3.300.0120.00820.09
8.3.290.0340.01018.28
8.3.280.0330.00718.18
8.3.270.0380.00716.41
8.3.260.0370.00616.62
8.3.250.0350.00916.46
8.3.240.0410.00616.70
8.3.230.0380.01116.68
8.3.220.0390.01116.56
8.3.210.0360.00916.60
8.3.200.0400.00716.37
8.3.190.0410.01116.20
8.3.180.0370.01216.63
8.3.170.0410.01116.35
8.3.160.0410.00616.51
8.3.150.0370.00516.45
8.3.140.0360.01316.56
8.3.130.0360.00916.64
8.3.120.0360.00516.52
8.3.110.0300.01016.46
8.3.100.0380.00816.69
8.3.90.0370.01116.52
8.3.80.0390.01016.73
8.3.70.0360.01016.79
8.3.60.0390.00716.68
8.3.50.0370.00716.72
8.3.40.0400.00617.82
8.3.30.0260.00917.72
8.3.20.0330.00717.91
8.3.10.0310.00717.87
8.3.00.0240.00717.89

preferences:
26.36 ms | 475 KiB | 5 Q