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 == '' || $nonce < 0 || $clientSeed == '' || $qty <= 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, int $qty): array { $preResult = hash(HASH_TYPE, $init); $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 = "$unhashedServerSeed-$clientSeed-$numberOfCase-$nonce"; $result = getProvablyFairResult($stringToHash, $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.4.130.0130.00818.68
8.4.120.0220.00721.40
8.4.110.0300.00917.86
8.4.100.0240.00617.75
8.4.90.0260.00717.66
8.4.80.0250.00817.76
8.4.70.0270.00617.72
8.4.60.0280.00817.70
8.4.50.0250.00717.87
8.4.40.0270.00617.53
8.4.30.0300.00717.60
8.4.20.0310.00717.58
8.4.10.0290.00717.57
8.3.260.0240.00516.47
8.3.250.0090.00618.38
8.3.240.0140.00616.68
8.3.230.0200.00616.47
8.3.220.0210.00516.50
8.3.210.0180.00616.42
8.3.200.0220.00616.49
8.3.190.0200.00516.62
8.3.180.0210.00516.73
8.3.170.0240.00516.53
8.3.160.0260.00616.75
8.3.150.0260.00616.57
8.3.140.0290.00616.59
8.3.130.0250.00516.48
8.3.120.0230.00816.60
8.3.110.0250.00616.63
8.3.100.0280.00716.58
8.3.90.0260.00816.82
8.3.80.0270.00816.51
8.3.70.0270.00616.42
8.3.60.0280.00616.50
8.3.50.0270.00616.46
8.3.40.0220.00717.86
8.3.30.0220.00617.93
8.3.20.0190.00618.40
8.3.10.0190.00518.44
8.3.00.0140.00618.84
8.2.290.0160.00616.89
8.2.280.0170.00616.48
8.2.270.0210.00616.47
8.2.260.0230.00716.62
8.2.250.0220.00716.54
8.2.240.0240.00616.45
8.2.230.0240.00616.52
8.2.220.0240.00816.70
8.2.210.0240.00616.69
8.2.200.0230.00716.48
8.2.190.0240.00516.43
8.2.180.0250.00616.40
8.2.170.0250.00718.00
8.2.160.0240.00718.17
8.2.150.0230.00718.21
8.2.140.0230.00718.30
8.2.130.0230.00719.02
8.2.120.0230.00618.89
8.2.110.0230.00618.87
8.2.100.0210.00718.89
8.2.90.0230.00718.87
8.2.80.0230.00618.84
8.2.70.0230.00718.77
8.2.60.0220.00618.83
8.2.50.0210.00618.84
8.2.40.0210.00718.87
8.2.30.0210.00518.77
8.2.20.0210.00618.82
8.2.10.0210.00618.78
8.2.00.0190.00718.76
8.1.330.0210.00516.70
8.1.320.0200.00616.07
8.1.310.0250.00715.96
8.1.300.0230.00616.05
8.1.290.0220.00816.50
8.1.280.0230.00616.43
8.1.270.0250.00518.28
8.1.260.0220.00719.12
8.1.250.0200.00819.08
8.1.240.0210.00618.63
8.1.230.0200.00718.65
8.1.220.0210.00618.61
8.1.210.0210.00818.57
8.1.200.0220.00618.59
8.1.190.0220.00618.52
8.1.180.0220.00718.48
8.1.170.0220.00718.67
8.1.160.0210.00618.62
8.1.150.0200.00718.65
8.1.140.0230.00518.59
8.1.130.0210.00618.60
8.1.120.0190.00818.64
8.1.110.0200.00518.62
8.1.100.0210.00618.75
8.1.90.0210.00718.61
8.1.80.0210.00718.77
8.1.70.0210.00718.68
8.1.60.0210.00818.75
8.1.50.0210.00718.69
8.1.40.0230.00718.73
8.1.30.0230.00718.79
8.1.20.0210.00718.94
8.1.10.0220.00718.67
8.1.00.0200.00718.54

preferences:
26.66 ms | 403 KiB | 5 Q