3v4l.org

run code in 300+ 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.4.120.0050.00525.85
8.4.110.0110.00922.53
8.4.100.0150.00617.86
8.4.90.0080.00820.32
8.4.80.0190.00918.43
8.4.70.0210.00918.56
8.4.60.0290.00818.02
8.4.50.0270.00717.99
8.4.40.0310.00917.52
8.4.30.0310.00617.61
8.4.20.0350.00717.54
8.4.10.0340.00817.73
8.3.250.0090.01018.81
8.3.240.0120.00717.30
8.3.230.0100.00916.40
8.3.220.0220.00818.33
8.3.210.0240.00717.03
8.3.200.0220.00617.02
8.3.190.0200.00816.97
8.3.180.0180.00517.67
8.3.170.0270.00817.07
8.3.160.0280.00717.21
8.3.150.0330.00616.97
8.3.140.0320.00616.69
8.3.130.0260.00916.58
8.3.120.0300.00816.73
8.3.110.0300.00816.79
8.3.100.0320.00716.66
8.3.90.0280.00719.96
8.3.80.0320.00817.60
8.3.70.0310.00817.60
8.3.60.0340.00919.48
8.3.50.0270.00719.46
8.3.40.0310.00820.06
8.3.30.0280.00820.30
8.3.20.0250.00820.91
8.3.10.0230.00821.18
8.3.00.0180.00821.22
8.2.290.0090.01021.94
8.2.280.0240.00817.21
8.2.270.0240.01016.85
8.2.260.0270.00816.72
8.2.250.0280.00716.67
8.2.240.0280.00716.69
8.2.230.0260.00716.76
8.2.220.0270.00716.91
8.2.210.0270.00817.90
8.2.200.0260.00717.52
8.2.190.0270.00817.55
8.2.180.0280.00819.40
8.2.170.0300.00720.19
8.2.160.0270.00820.47
8.2.150.0250.00720.97
8.2.140.0240.00720.98
8.2.130.0250.00821.24
8.2.120.0250.00821.47
8.2.110.0260.00721.13
8.2.100.0250.00721.10
8.2.90.0260.00721.10
8.2.80.0270.00721.09
8.2.70.0270.00721.01
8.2.60.0260.00821.01
8.2.50.0250.00821.06
8.2.40.0250.00721.03
8.2.30.0240.00821.02
8.2.20.0230.00721.02
8.2.10.0210.00821.03
8.2.00.0240.00721.00
8.1.330.0030.00523.79
8.1.320.0240.00716.75
8.1.310.0240.00816.32
8.1.300.0270.00616.22
8.1.290.0270.00617.95
8.1.280.0280.00919.49
8.1.270.0240.00821.13
8.1.260.0250.00821.40
8.1.250.0240.00721.46
8.1.240.0210.00820.93
8.1.230.0230.00820.95
8.1.220.0230.00821.01
8.1.210.0220.00920.88
8.1.200.0220.00820.90
8.1.190.0230.00720.87
8.1.180.0220.00920.83
8.1.170.0240.00720.91
8.1.160.0230.00720.90
8.1.150.0240.00720.93
8.1.140.0220.00720.89
8.1.130.0220.00720.96
8.1.120.0210.00820.95
8.1.110.0220.00720.92
8.1.100.0220.00820.92
8.1.90.0230.00820.92
8.1.80.0220.00721.04
8.1.70.0210.00820.92
8.1.60.0230.00821.00
8.1.50.0240.00720.96
8.1.40.0260.00620.95
8.1.30.0240.00721.02
8.1.20.0250.00821.13
8.1.10.0250.00720.96
8.1.00.0230.00720.89

preferences:
29.96 ms | 403 KiB | 5 Q