3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Fill in all five below and click the blue 'eval();' button. * ------------------ */ $numberOfCase = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $qty = -1; /* ------------------ */ if ($numberOfCase < 0 || $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); $stringToHash = "$unhashedServerSeed-$clientSeed-$numberOfCase-$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.0180.00622.37
8.4.110.0290.00917.89
8.4.100.0250.00617.72
8.4.90.0260.00717.70
8.4.80.0240.00817.77
8.4.70.0270.00617.70
8.4.60.0280.00817.71
8.4.50.0250.00717.89
8.4.40.0270.00617.53
8.4.30.0310.00717.61
8.4.20.0310.00717.58
8.4.10.0300.00717.57
8.3.250.0070.00618.86
8.3.240.0140.00516.68
8.3.230.0200.00616.46
8.3.220.0220.00516.48
8.3.210.0190.00616.41
8.3.200.0220.00616.48
8.3.190.0200.00516.63
8.3.180.0220.00516.77
8.3.170.0240.00616.55
8.3.160.0260.00616.75
8.3.150.0260.00616.56
8.3.140.0300.00616.51
8.3.130.0250.00516.49
8.3.120.0230.00816.61
8.3.110.0260.00616.64
8.3.100.0280.00816.60
8.3.90.0270.00816.84
8.3.80.0270.00816.52
8.3.70.0280.00716.41
8.3.60.0280.00616.51
8.3.50.0280.00616.47
8.3.40.0220.00717.89
8.3.30.0220.00617.95
8.3.20.0190.00618.43
8.3.10.0190.00518.48
8.3.00.0150.00618.91
8.2.290.0160.00616.99
8.2.280.0170.00616.49
8.2.270.0210.00616.47
8.2.260.0230.00716.63
8.2.250.0220.00716.55
8.2.240.0240.00616.46
8.2.230.0240.00616.55
8.2.220.0240.00816.72
8.2.210.0240.00616.71
8.2.200.0230.00716.50
8.2.190.0250.00616.45
8.2.180.0250.00616.40
8.2.170.0250.00718.02
8.2.160.0250.00718.20
8.2.150.0230.00718.24
8.2.140.0240.00718.34
8.2.130.0230.00719.08
8.2.120.0230.00718.93
8.2.110.0240.00618.92
8.2.100.0220.00718.94
8.2.90.0230.00718.93
8.2.80.0240.00618.90
8.2.70.0230.00718.81
8.2.60.0220.00718.87
8.2.50.0210.00718.90
8.2.40.0210.00718.92
8.2.30.0210.00518.81
8.2.20.0210.00718.87
8.2.10.0220.00618.83
8.2.00.0190.00718.81
8.1.330.0210.00616.76
8.1.320.0210.00616.05
8.1.310.0250.00815.96
8.1.300.0230.00616.05
8.1.290.0220.00816.52
8.1.280.0230.00616.45
8.1.270.0250.00518.32
8.1.260.0210.00719.17
8.1.250.0200.00819.14
8.1.240.0210.00618.67
8.1.230.0190.00718.69
8.1.220.0210.00618.66
8.1.210.0200.00818.61
8.1.200.0220.00618.64
8.1.190.0210.00718.57
8.1.180.0210.00718.52
8.1.170.0210.00718.71
8.1.160.0210.00618.66
8.1.150.0200.00718.69
8.1.140.0230.00518.63
8.1.130.0210.00618.64
8.1.120.0190.00718.68
8.1.110.0200.00518.67
8.1.100.0210.00618.80
8.1.90.0210.00818.65
8.1.80.0210.00718.83
8.1.70.0210.00618.72
8.1.60.0210.00818.80
8.1.50.0200.00718.73
8.1.40.0220.00718.77
8.1.30.0230.00718.84
8.1.20.0210.00719.00
8.1.10.0210.00718.72
8.1.00.0200.00718.59

preferences:
27.62 ms | 403 KiB | 5 Q