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.5.30.0110.00618.16
8.5.20.0140.01117.34
8.5.10.0250.01116.94
8.5.00.0220.00917.42
8.4.180.0260.01020.81
8.4.170.0250.01021.22
8.4.160.0250.01021.01
8.4.150.0210.00718.22
8.4.140.0270.00717.53
8.4.130.0210.00717.52
8.4.120.0250.00919.77
8.4.110.0270.00918.84
8.4.100.0320.00817.75
8.4.90.0290.01018.51
8.4.80.0290.00918.05
8.4.70.0280.00918.29
8.4.60.0350.00917.87
8.4.50.0310.00817.92
8.4.40.0340.01017.52
8.4.30.0340.00717.61
8.4.20.0370.00817.55
8.4.10.0360.00917.69
8.3.300.0270.00918.58
8.3.290.0280.00818.98
8.3.280.0280.00818.28
8.3.270.0300.00816.59
8.3.260.0320.01016.60
8.3.250.0280.00917.14
8.3.240.0320.00816.80
8.3.230.0290.00816.54
8.3.220.0290.00817.52
8.3.210.0310.00816.87
8.3.200.0290.00716.81
8.3.190.0270.00816.81
8.3.180.0240.00717.28
8.3.170.0310.00816.86
8.3.160.0310.00817.01
8.3.150.0340.00716.87
8.3.140.0340.00716.66
8.3.130.0280.00916.57
8.3.120.0310.00816.71
8.3.110.0300.00816.74
8.3.100.0330.00816.63
8.3.90.0290.00719.63
8.3.80.0330.00817.47
8.3.70.0320.00917.47
8.3.60.0340.00919.18
8.3.50.0280.00819.17
8.3.40.0310.00819.84
8.3.30.0280.00820.06
8.3.20.0250.00820.66
8.3.10.0230.00820.92
8.3.00.0190.00820.97
8.2.300.0330.00818.46
8.2.290.0260.00717.92
8.2.280.0260.00716.98
8.2.270.0260.01016.74
8.2.260.0270.00916.66
8.2.250.0280.00716.65
8.2.240.0280.00716.64
8.2.230.0260.00716.69
8.2.220.0270.00816.86
8.2.210.0270.00817.71
8.2.200.0270.00717.38
8.2.190.0270.00817.40
8.2.180.0280.00819.09
8.2.170.0300.00719.98
8.2.160.0270.00820.24
8.2.150.0260.00720.73
8.2.140.0240.00720.74
8.2.130.0250.00820.97
8.2.120.0250.00821.21
8.2.110.0260.00720.89
8.2.100.0250.00820.86
8.2.90.0260.00720.86
8.2.80.0270.00720.85
8.2.70.0270.00720.78
8.2.60.0260.00820.78
8.2.50.0250.00820.82
8.2.40.0250.00720.80
8.2.30.0250.00820.78
8.2.20.0240.00720.77
8.2.10.0220.00820.78
8.2.00.0240.00820.76
8.1.340.0240.00917.66
8.1.330.0200.00918.10
8.1.320.0260.00716.45
8.1.310.0240.00816.26
8.1.300.0260.00716.19
8.1.290.0280.00717.71
8.1.280.0280.00919.15
8.1.270.0250.00820.86
8.1.260.0250.00821.11
8.1.250.0240.00721.17
8.1.240.0210.00820.69
8.1.230.0230.00820.71
8.1.220.0230.00820.76
8.1.210.0220.00920.64
8.1.200.0220.00820.65
8.1.190.0240.00720.62
8.1.180.0230.00920.60
8.1.170.0240.00720.67
8.1.160.0240.00720.65
8.1.150.0240.00720.68
8.1.140.0220.00720.65
8.1.130.0220.00720.72
8.1.120.0220.00820.70
8.1.110.0220.00720.68
8.1.100.0220.00820.68
8.1.90.0230.00820.68
8.1.80.0230.00720.79
8.1.70.0220.00820.68
8.1.60.0240.00820.76
8.1.50.0240.00720.73
8.1.40.0270.00620.71
8.1.30.0240.00720.79
8.1.20.0250.00820.89
8.1.10.0250.00720.72
8.1.00.0240.00720.65

preferences:
47.91 ms | 991 KiB | 5 Q