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.20.0080.01017.86
8.5.10.0200.01117.21
8.5.00.0170.00818.44
8.4.170.0100.01023.90
8.4.160.0200.01122.23
8.4.150.0180.00416.84
8.4.140.0260.00617.72
8.4.130.0180.00817.52
8.4.120.0190.00921.85
8.4.110.0260.00920.05
8.4.100.0250.00817.72
8.4.90.0200.01119.13
8.4.80.0220.01018.28
8.4.70.0250.00918.46
8.4.60.0300.00917.96
8.4.50.0280.00717.96
8.4.40.0320.01017.51
8.4.30.0320.00617.61
8.4.20.0360.00817.54
8.4.10.0350.00817.72
8.3.300.0140.00719.19
8.3.290.0260.00719.51
8.3.280.0210.00918.29
8.3.270.0230.00816.52
8.3.260.0220.00916.65
8.3.250.0200.01117.71
8.3.240.0260.00817.03
8.3.230.0210.01016.51
8.3.220.0250.00917.92
8.3.210.0280.00716.92
8.3.200.0260.00716.91
8.3.190.0230.00816.94
8.3.180.0210.00517.48
8.3.170.0280.00816.97
8.3.160.0290.00817.13
8.3.150.0330.00616.91
8.3.140.0330.00616.68
8.3.130.0270.00816.58
8.3.120.0310.00816.72
8.3.110.0300.00816.77
8.3.100.0330.00716.66
8.3.90.0290.00719.84
8.3.80.0330.00817.55
8.3.70.0320.00817.55
8.3.60.0340.00819.37
8.3.50.0280.00719.36
8.3.40.0310.00819.98
8.3.30.0280.00920.22
8.3.20.0250.00820.82
8.3.10.0230.00821.09
8.3.00.0180.00821.13
8.2.300.0270.00819.09
8.2.290.0210.01019.24
8.2.280.0250.00717.11
8.2.270.0250.01016.79
8.2.260.0270.00816.71
8.2.250.0280.00716.65
8.2.240.0280.00716.68
8.2.230.0260.00716.74
8.2.220.0270.00816.89
8.2.210.0270.00817.83
8.2.200.0260.00717.46
8.2.190.0270.00817.49
8.2.180.0280.00819.29
8.2.170.0300.00720.12
8.2.160.0270.00820.39
8.2.150.0260.00720.88
8.2.140.0240.00720.89
8.2.130.0250.00821.14
8.2.120.0250.00821.38
8.2.110.0260.00721.04
8.2.100.0250.00821.01
8.2.90.0260.00721.01
8.2.80.0270.00721.01
8.2.70.0270.00720.93
8.2.60.0260.00820.93
8.2.50.0250.00820.97
8.2.40.0250.00720.95
8.2.30.0240.00820.94
8.2.20.0240.00720.93
8.2.10.0220.00820.94
8.2.00.0240.00820.91
8.1.340.0180.00917.93
8.1.330.0150.00819.95
8.1.320.0240.00816.63
8.1.310.0240.00816.29
8.1.300.0270.00616.21
8.1.290.0280.00617.87
8.1.280.0280.00919.38
8.1.270.0240.00821.03
8.1.260.0250.00821.30
8.1.250.0240.00721.36
8.1.240.0210.00820.85
8.1.230.0230.00820.86
8.1.220.0230.00820.92
8.1.210.0220.00920.79
8.1.200.0220.00820.81
8.1.190.0230.00720.78
8.1.180.0220.00920.75
8.1.170.0240.00720.83
8.1.160.0230.00720.81
8.1.150.0240.00720.84
8.1.140.0220.00720.80
8.1.130.0220.00720.88
8.1.120.0210.00820.86
8.1.110.0220.00720.84
8.1.100.0220.00820.83
8.1.90.0230.00820.83
8.1.80.0230.00720.95
8.1.70.0210.00820.84
8.1.60.0230.00820.92
8.1.50.0240.00820.88
8.1.40.0270.00620.86
8.1.30.0240.00720.94
8.1.20.0250.00821.05
8.1.10.0250.00720.88
8.1.00.0230.00720.81

preferences:
45.57 ms | 403 KiB | 5 Q