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 = ''; $qty = -1; /* ------------------ */ if ($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); $nrand = strlen($clientSeed); $stringToHash = "$unhashedServerSeed-$clientSeed-$nrand-$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.5.70.0250.00816.63
8.5.60.0200.00816.52
8.5.50.0170.00616.41
8.5.40.0280.00716.38
8.5.30.0200.00717.14
8.5.20.0190.00816.97
8.5.10.0250.00916.85
8.5.00.0150.00717.12
8.4.220.0210.00819.46
8.4.210.0220.00819.38
8.4.200.0280.00519.56
8.4.190.0260.00619.45
8.4.180.0270.01019.97
8.4.170.0240.00920.38
8.4.160.0240.00920.28
8.4.150.0230.00718.72
8.4.140.0260.00717.54
8.4.130.0220.00717.54
8.4.120.0250.00818.86
8.4.110.0250.00618.36
8.4.100.0280.00717.71
8.4.90.0260.00818.19
8.4.80.0270.00917.93
8.4.70.0280.00818.13
8.4.60.0320.00817.80
8.4.50.0290.00717.84
8.4.40.0310.00917.56
8.4.30.0300.00717.61
8.4.20.0330.00717.52
8.4.10.0340.00817.66
8.3.310.0150.00618.49
8.3.300.0250.00718.42
8.3.290.0250.00618.70
8.3.280.0230.00818.24
8.3.270.0260.00716.57
8.3.260.0250.00816.60
8.3.250.0250.00816.86
8.3.240.0270.00716.71
8.3.230.0270.00716.55
8.3.220.0260.00817.22
8.3.210.0280.00716.75
8.3.200.0270.00716.73
8.3.190.0260.00716.72
8.3.180.0230.00717.08
8.3.170.0300.00716.77
8.3.160.0290.00716.91
8.3.150.0320.00616.81
8.3.140.0310.00616.65
8.3.130.0260.00816.57
8.3.120.0290.00816.69
8.3.110.0290.00816.72
8.3.100.0310.00816.61
8.3.90.0280.00719.36
8.3.80.0320.00817.38
8.3.70.0310.00817.35
8.3.60.0330.00818.94
8.3.50.0270.00718.95
8.3.40.0300.00819.66
8.3.30.0270.00819.87
8.3.20.0240.00820.44
8.3.10.0230.00820.71
8.3.00.0190.00820.75
8.2.310.0250.00517.79
8.2.300.0270.00718.24
8.2.290.0210.00617.39
8.2.280.0240.00716.88
8.2.270.0240.00916.69
8.2.260.0250.00816.63
8.2.250.0270.00716.64
8.2.240.0260.00716.60
8.2.230.0240.00716.66
8.2.220.0260.00716.81
8.2.210.0260.00717.55
8.2.200.0250.00717.26
8.2.190.0260.00817.30
8.2.180.0270.00818.86
8.2.170.0290.00719.79
8.2.160.0260.00820.05
8.2.150.0250.00720.52
8.2.140.0240.00720.52
8.2.130.0250.00820.75
8.2.120.0240.00821.00
8.2.110.0260.00720.68
8.2.100.0250.00820.64
8.2.90.0250.00720.65
8.2.80.0260.00720.65
8.2.70.0270.00720.56
8.2.60.0250.00820.57
8.2.50.0240.00820.61
8.2.40.0250.00720.59
8.2.30.0240.00820.57
8.2.20.0240.00720.55
8.2.10.0220.00820.57
8.2.00.0240.00820.55
8.1.340.0240.00817.60
8.1.330.0210.00717.26
8.1.320.0240.00616.35
8.1.310.0240.00716.22
8.1.300.0250.00716.17
8.1.290.0270.00717.53
8.1.280.0270.00818.87
8.1.270.0240.00720.62
8.1.260.0250.00820.87
8.1.250.0240.00720.93
8.1.240.0210.00820.47
8.1.230.0220.00820.49
8.1.220.0230.00720.54
8.1.210.0220.00920.42
8.1.200.0220.00820.43
8.1.190.0230.00720.40
8.1.180.0220.00920.37
8.1.170.0240.00720.46
8.1.160.0240.00720.44
8.1.150.0240.00720.46
8.1.140.0220.00720.43
8.1.130.0220.00720.50
8.1.120.0220.00720.49
8.1.110.0220.00720.47
8.1.100.0220.00820.47
8.1.90.0230.00820.47
8.1.80.0220.00720.57
8.1.70.0210.00820.47
8.1.60.0240.00820.55
8.1.50.0240.00820.53
8.1.40.0260.00620.51
8.1.30.0240.00720.58
8.1.20.0250.00820.68
8.1.10.0250.00720.51
8.1.00.0240.00720.44

preferences:
55.68 ms | 1025 KiB | 5 Q