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.0120.00519.73
8.5.20.0080.01017.62
8.5.10.0240.01117.00
8.5.00.0190.00817.68
8.4.170.0210.00922.16
8.4.160.0240.01021.60
8.4.150.0240.00517.80
8.4.140.0250.00717.61
8.4.130.0190.00817.54
8.4.120.0270.01120.45
8.4.110.0300.01019.23
8.4.100.0300.00817.75
8.4.90.0270.00918.71
8.4.80.0260.01018.14
8.4.70.0270.00918.36
8.4.60.0330.01017.90
8.4.50.0290.00817.94
8.4.40.0330.01017.52
8.4.30.0330.00617.62
8.4.20.0370.00817.54
8.4.10.0360.00817.70
8.3.300.0240.00818.73
8.3.290.0270.00819.18
8.3.280.0260.00918.30
8.3.270.0270.00916.54
8.3.260.0300.01016.64
8.3.250.0260.01017.33
8.3.240.0300.00816.89
8.3.230.0260.01016.50
8.3.220.0270.00917.67
8.3.210.0290.00716.90
8.3.200.0280.00716.87
8.3.190.0250.00816.87
8.3.180.0230.00617.35
8.3.170.0300.00816.89
8.3.160.0300.00817.05
8.3.150.0340.00616.89
8.3.140.0340.00616.67
8.3.130.0270.00916.58
8.3.120.0310.00816.71
8.3.110.0300.00816.76
8.3.100.0330.00716.65
8.3.90.0290.00719.73
8.3.80.0330.00817.51
8.3.70.0320.00817.50
8.3.60.0340.00919.27
8.3.50.0280.00719.26
8.3.40.0310.00819.91
8.3.30.0280.00820.14
8.3.20.0250.00820.74
8.3.10.0230.00821.00
8.3.00.0190.00821.05
8.2.300.0340.00818.70
8.2.290.0240.00918.38
8.2.280.0260.00817.03
8.2.270.0250.01016.76
8.2.260.0270.00816.68
8.2.250.0280.00716.65
8.2.240.0280.00716.66
8.2.230.0260.00716.71
8.2.220.0270.00816.87
8.2.210.0270.00817.76
8.2.200.0270.00717.42
8.2.190.0270.00817.45
8.2.180.0280.00819.19
8.2.170.0300.00720.05
8.2.160.0270.00820.31
8.2.150.0260.00720.80
8.2.140.0240.00720.81
8.2.130.0250.00821.06
8.2.120.0250.00821.30
8.2.110.0260.00720.96
8.2.100.0250.00820.93
8.2.90.0260.00720.94
8.2.80.0270.00720.93
8.2.70.0280.00720.85
8.2.60.0260.00820.85
8.2.50.0250.00820.89
8.2.40.0250.00720.87
8.2.30.0250.00820.86
8.2.20.0240.00720.84
8.2.10.0220.00820.86
8.2.00.0240.00820.83
8.1.340.0220.01017.81
8.1.330.0180.01018.71
8.1.320.0250.00816.54
8.1.310.0250.00816.28
8.1.300.0270.00716.19
8.1.290.0280.00617.78
8.1.280.0280.00919.26
8.1.270.0240.00820.94
8.1.260.0250.00821.21
8.1.250.0240.00721.27
8.1.240.0210.00820.77
8.1.230.0230.00820.78
8.1.220.0230.00820.84
8.1.210.0220.00920.72
8.1.200.0220.00820.73
8.1.190.0240.00720.69
8.1.180.0230.00920.67
8.1.170.0240.00720.75
8.1.160.0230.00720.73
8.1.150.0240.00720.76
8.1.140.0220.00720.72
8.1.130.0220.00720.79
8.1.120.0210.00820.78
8.1.110.0220.00720.76
8.1.100.0220.00820.75
8.1.90.0230.00820.75
8.1.80.0230.00720.87
8.1.70.0220.00820.76
8.1.60.0240.00820.84
8.1.50.0240.00820.81
8.1.40.0270.00620.79
8.1.30.0240.00720.86
8.1.20.0250.00820.97
8.1.10.0250.00720.80
8.1.00.0230.00720.73

preferences:
36.6 ms | 403 KiB | 5 Q