3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all four below and click the blue 'eval();' button. * ------------------ */ $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $ticketQuantity = -1; /* ------------------ */ if ($unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $ticketQuantity <= 0) { echo "bce2e1376976a5c312e94fe9a8f3bcfbbce2e1376976a5c312e94fe9a8f3bcfb"; 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); $nrand = strlen($clientSeed); $stringToHash = "$clientSeed-$nrand-$nonce"; $result = getProvablyFairResult($stringToHash, $unhashedServerSeed, $ticketQuantity); 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.90.0300.01116.77
8.5.80.0390.00716.53
8.5.70.0330.00616.63
8.5.60.0370.00516.55
8.5.50.0330.00816.32
8.5.40.0320.00716.35
8.5.30.0330.00716.88
8.5.20.0340.00716.64
8.5.10.0370.01016.64
8.5.00.0110.00516.76
8.4.240.0260.01119.28
8.4.230.0290.01319.64
8.4.220.0300.01219.34
8.4.210.0350.00719.46
8.4.200.0320.00819.46
8.4.190.0330.01019.42
8.4.180.0300.01219.35
8.4.170.0330.00919.61
8.4.160.0310.01019.35
8.4.150.0240.01219.67
8.4.140.0310.01017.60
8.4.130.0320.01117.65
8.4.120.0330.00917.79
8.4.110.0360.00917.79
8.4.100.0350.01017.88
8.4.90.0340.01017.76
8.4.80.0350.00917.81
8.4.70.0350.00817.86
8.4.60.0170.00717.85
8.4.50.0240.00517.71
8.4.40.0330.01017.85
8.4.30.0230.00417.64
8.4.20.0150.00417.70
8.4.10.0240.00917.48
8.3.330.0350.00818.14
8.3.320.0340.00918.25
8.3.310.0310.01018.16
8.3.300.0320.00918.39
8.3.290.0310.00918.26
8.3.280.0270.01417.91
8.3.270.0330.01016.69
8.3.260.0330.00516.57
8.3.250.0320.01016.73
8.3.240.0390.00516.45
8.3.230.0300.01116.58
8.3.220.0340.00916.68
8.3.210.0370.00716.59
8.3.200.0290.01116.82
8.3.190.0320.00616.50
8.3.180.0340.00616.60
8.3.170.0350.01116.41
8.3.160.0390.00516.80
8.3.150.0220.00516.59
8.3.140.0360.01016.71
8.3.130.0230.00816.59
8.3.120.0280.00816.77
8.3.110.0290.00916.65
8.3.100.0320.01016.65
8.3.90.0370.00816.64
8.3.80.0330.00716.58
8.3.70.0330.00816.41
8.3.60.0320.01016.70
8.3.50.0390.00616.54
8.3.40.0380.00717.72
8.3.30.0300.00417.82
8.3.20.0340.00417.57
8.3.10.0300.00817.96
8.3.00.0250.00717.89
8.2.330.0420.01317.83
8.2.320.0350.01117.92
8.2.310.0320.00817.96

preferences:
49.1 ms | 773 KiB | 5 Q