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.90.0210.00816.89
8.5.80.0180.00716.80
8.5.70.0260.00816.57
8.5.60.0220.00816.50
8.5.50.0200.00616.42
8.5.40.0280.00716.38
8.5.30.0230.00717.02
8.5.20.0210.00816.95
8.5.10.0250.00916.80
8.5.00.0150.00717.06
8.4.240.0220.00919.38
8.4.230.0230.00919.43
8.4.220.0220.00919.46
8.4.210.0230.00919.41
8.4.200.0270.00519.54
8.4.190.0280.00719.47
8.4.180.0270.01019.89
8.4.170.0250.00920.27
8.4.160.0260.00920.19
8.4.150.0240.00718.82
8.4.140.0270.00717.53
8.4.130.0230.00817.54
8.4.120.0250.00718.74
8.4.110.0240.00618.30
8.4.100.0290.00717.74
8.4.90.0260.00918.13
8.4.80.0280.00917.93
8.4.70.0280.00818.09
8.4.60.0320.00817.81
8.4.50.0300.00717.83
8.4.40.0310.00917.57
8.4.30.0300.00717.60
8.4.20.0320.00717.52
8.4.10.0340.00717.65
8.3.330.0280.00718.36
8.3.320.0250.00918.41
8.3.310.0180.00718.45
8.3.300.0260.00718.40
8.3.290.0260.00718.65
8.3.280.0240.00818.24
8.3.270.0260.00716.58
8.3.260.0270.00816.62
8.3.250.0260.00816.81
8.3.240.0270.00716.71
8.3.230.0270.00716.56
8.3.220.0270.00817.16
8.3.210.0280.00716.76
8.3.200.0270.00716.73
8.3.190.0270.00716.72
8.3.180.0240.00717.04
8.3.170.0300.00816.75
8.3.160.0300.00716.90
8.3.150.0320.00716.78
8.3.140.0320.00616.64
8.3.130.0260.00816.56
8.3.120.0290.00816.69
8.3.110.0290.00816.72
8.3.100.0320.00816.62
8.3.90.0280.00719.28
8.3.80.0320.00817.35
8.3.70.0310.00817.33
8.3.60.0330.00818.87
8.3.50.0270.00718.87
8.3.40.0300.00819.59
8.3.30.0270.00819.82
8.3.20.0240.00820.37
8.3.10.0230.00820.64
8.3.00.0190.00820.68
8.2.330.0470.00717.93
8.2.320.0210.00918.02
8.2.310.0270.00617.86
8.2.300.0270.00718.22
8.2.290.0220.00617.31
8.2.280.0240.00716.86
8.2.270.0250.00916.66
8.2.260.0250.00816.62
8.2.250.0270.00716.64
8.2.240.0260.00716.59
8.2.230.0250.00716.65
8.2.220.0260.00716.79
8.2.210.0260.00717.52
8.2.200.0250.00717.23
8.2.190.0260.00817.27
8.2.180.0270.00818.79
8.2.170.0290.00719.74
8.2.160.0260.00820.00
8.2.150.0250.00720.47
8.2.140.0240.00720.46
8.2.130.0250.00820.68
8.2.120.0240.00820.93
8.2.110.0260.00820.62
8.2.100.0250.00820.58
8.2.90.0250.00720.59
8.2.80.0260.00720.58
8.2.70.0270.00720.50
8.2.60.0250.00820.51
8.2.50.0240.00820.55
8.2.40.0240.00720.52
8.2.30.0250.00820.51
8.2.20.0240.00720.49
8.2.10.0220.00820.50
8.2.00.0240.00820.49
8.1.340.0240.00817.60
8.1.330.0220.00717.14
8.1.320.0240.00716.32
8.1.310.0240.00716.21
8.1.300.0250.00716.16
8.1.290.0270.00717.48
8.1.280.0270.00818.79
8.1.270.0240.00820.56
8.1.260.0250.00820.80
8.1.250.0240.00720.85
8.1.240.0210.00820.40
8.1.230.0220.00820.42
8.1.220.0230.00720.48
8.1.210.0220.00920.36
8.1.200.0220.00820.36
8.1.190.0230.00720.34
8.1.180.0220.00920.31
8.1.170.0240.00720.40
8.1.160.0240.00720.38
8.1.150.0240.00720.40
8.1.140.0220.00820.37
8.1.130.0220.00720.44
8.1.120.0220.00720.43
8.1.110.0220.00720.41
8.1.100.0220.00820.40
8.1.90.0230.00820.41
8.1.80.0220.00720.51
8.1.70.0210.00820.40
8.1.60.0240.00820.49
8.1.50.0240.00720.46
8.1.40.0260.00620.45
8.1.30.0240.00720.52
8.1.20.0250.00820.61
8.1.10.0250.00720.45
8.1.00.0240.00720.37

preferences:
52.62 ms | 1049 KiB | 5 Q