3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all four below and click the blue 'eval();' button. * ------------------ */ $unhashedServerSeed = 'JJtIyuRvwSVJS9PyU0KJ3VRN3GQAxI8tDRe0M7g7unaTsIohquMo8FgtCLVwSW4y'; $nonce = 40; $clientSeed = 'I2ApzlvbpQJBO88E4wDcTxLVusE6pQKe'; $ticketQuantity = 1000000; /* ------------------ */ if ($unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $ticketQuantity <= 0) { 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); $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.0220.00617.09
8.5.80.0260.01016.81
8.5.70.0170.00617.15
8.5.60.0210.00716.75
8.5.50.0270.00916.75
8.5.40.0330.00516.82
8.5.30.0250.00717.19
8.5.20.0230.00617.00
8.5.10.0290.00716.65
8.5.00.0100.00916.93
8.4.240.0050.00519.87
8.4.230.0140.00619.63
8.4.220.0170.01219.80
8.4.210.0250.00919.91
8.4.200.0230.00419.61
8.4.190.0130.00719.84
8.4.180.0160.00519.72
8.4.170.0210.00520.06
8.4.160.0190.00119.81
8.4.150.0170.00519.96
8.4.140.0140.00417.82
8.4.130.0170.00317.77
8.4.120.0160.00517.87
8.4.110.0160.00718.16
8.4.100.0130.00618.03
8.4.90.0190.00717.89
8.4.80.0240.00717.82
8.4.70.0230.00517.87
8.4.60.0230.00518.00
8.4.50.0240.01017.96
8.4.40.0180.00617.99
8.4.30.0170.00618.16
8.4.20.0140.00618.04
8.4.10.0170.00517.85
8.3.330.0270.00718.41
8.3.320.0170.00018.66
8.3.310.0170.00318.63
8.3.300.0150.00518.45
8.3.290.0140.01018.39
8.3.280.0170.00218.47
8.3.270.0210.00416.79
8.3.260.0160.00316.91
8.3.250.0190.00216.90
8.3.240.0160.00416.80
8.3.230.0170.00316.73
8.3.220.0130.00616.93
8.3.210.0200.00817.02
8.3.200.0170.00316.95
8.3.190.0160.00317.00
8.3.180.0150.00416.76
8.3.170.0180.00516.70
8.3.160.0170.00417.02
8.3.150.0150.00516.77
8.3.140.0190.00116.92
8.3.130.0140.00316.61
8.3.120.0110.00616.94
8.3.110.0130.00516.92
8.3.100.0220.00317.07
8.3.90.0260.00717.01
8.3.80.0310.00716.80
8.3.70.0240.00317.14
8.3.60.0330.00216.86
8.3.50.0280.00816.85
8.3.40.0330.00718.23
8.3.30.0280.00818.22
8.3.20.0250.00618.12
8.3.10.0140.00718.30
8.3.00.0280.00818.20
8.2.330.0210.00618.08
8.2.320.0120.00618.12
8.2.310.0130.00618.11

preferences:
54 ms | 777 KiB | 5 Q