3v4l.org

run code in 500+ 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.5.30.0100.00817.58
8.5.20.0250.00816.97
8.5.10.0260.00717.06
8.5.00.0250.00917.66
8.4.180.0220.00920.63
8.4.170.0250.01020.43
8.4.160.0270.00920.29
8.4.150.0250.00618.15
8.4.140.0260.01117.58
8.4.130.0250.00818.15
8.4.120.0260.00820.37
8.4.110.0310.00917.83
8.4.100.0260.00717.75
8.4.90.0280.00717.69
8.4.80.0250.00817.79
8.4.70.0280.00617.75
8.4.60.0290.00817.71
8.4.50.0250.00717.85
8.4.40.0270.00617.54
8.4.30.0300.00617.60
8.4.20.0310.00717.58
8.4.10.0300.00717.57
8.3.300.0180.00518.89
8.3.290.0210.00719.22
8.3.280.0200.00618.39
8.3.270.0220.00616.64
8.3.260.0260.00616.54
8.3.250.0140.00617.87
8.3.240.0170.00616.67
8.3.230.0220.00616.50
8.3.220.0220.00516.53
8.3.210.0210.00616.45
8.3.200.0230.00516.52
8.3.190.0210.00516.60
8.3.180.0230.00616.70
8.3.170.0260.00616.54
8.3.160.0260.00616.74
8.3.150.0260.00716.56
8.3.140.0290.00616.60
8.3.130.0240.00516.48
8.3.120.0230.00716.60
8.3.110.0250.00616.63
8.3.100.0270.00716.57
8.3.90.0260.00816.80
8.3.80.0270.00716.51
8.3.70.0270.00616.44
8.3.60.0270.00616.50
8.3.50.0280.00616.47
8.3.40.0230.00717.86
8.3.30.0220.00617.92
8.3.20.0190.00618.36
8.3.10.0190.00518.40
8.3.00.0140.00618.78
8.2.300.0340.00718.61
8.2.290.0180.00616.85
8.2.280.0190.00616.48
8.2.270.0210.00616.47
8.2.260.0230.00716.59
8.2.250.0220.00716.53
8.2.240.0240.00616.45
8.2.230.0240.00616.52
8.2.220.0230.00816.68
8.2.210.0240.00616.68
8.2.200.0230.00716.49
8.2.190.0240.00516.44
8.2.180.0250.00616.40
8.2.170.0250.00718.00
8.2.160.0250.00718.15
8.2.150.0240.00718.19
8.2.140.0240.00718.27
8.2.130.0230.00718.95
8.2.120.0230.00718.83
8.2.110.0240.00618.81
8.2.100.0220.00718.83
8.2.90.0230.00718.82
8.2.80.0240.00618.77
8.2.70.0230.00718.71
8.2.60.0220.00718.78
8.2.50.0210.00718.78
8.2.40.0210.00718.80
8.2.30.0210.00618.71
8.2.20.0210.00618.76
8.2.10.0220.00618.72
8.2.00.0190.00718.71
8.1.340.0270.00817.47
8.1.330.0220.00616.59
8.1.320.0210.00616.08
8.1.310.0240.00715.96
8.1.300.0220.00616.05
8.1.290.0210.00716.47
8.1.280.0230.00616.41
8.1.270.0250.00518.24
8.1.260.0220.00719.03
8.1.250.0210.00818.99
8.1.240.0210.00618.56
8.1.230.0200.00718.59
8.1.220.0210.00618.54
8.1.210.0210.00818.51
8.1.200.0220.00618.52
8.1.190.0220.00718.45
8.1.180.0220.00718.41
8.1.170.0220.00718.60
8.1.160.0220.00618.56
8.1.150.0210.00718.59
8.1.140.0230.00518.52
8.1.130.0220.00618.54
8.1.120.0190.00818.58
8.1.110.0200.00618.57
8.1.100.0210.00718.69
8.1.90.0220.00818.55
8.1.80.0210.00718.70
8.1.70.0220.00718.62
8.1.60.0210.00818.69
8.1.50.0210.00718.63
8.1.40.0230.00718.68
8.1.30.0230.00718.74
8.1.20.0210.00718.87
8.1.10.0220.00718.61
8.1.00.0210.00718.47

preferences:
67.16 ms | 976 KiB | 5 Q