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.5.30.0090.00918.09
8.5.20.0200.01017.18
8.5.10.0230.00717.41
8.5.00.0210.01018.18
8.4.180.0190.00921.00
8.4.170.0210.01020.79
8.4.160.0250.00720.63
8.4.150.0240.00517.69
8.4.140.0240.01017.56
8.4.130.0220.00818.36
8.4.120.0250.00820.79
8.4.110.0300.00917.82
8.4.100.0250.00617.76
8.4.90.0270.00717.68
8.4.80.0240.00817.78
8.4.70.0260.00617.73
8.4.60.0280.00817.71
8.4.50.0260.00817.85
8.4.40.0280.00617.53
8.4.30.0300.00717.60
8.4.20.0310.00717.58
8.4.10.0300.00717.57
8.3.300.0190.00619.20
8.3.290.0260.00719.59
8.3.280.0230.00718.29
8.3.270.0230.00816.61
8.3.260.0280.00716.56
8.3.250.0130.00618.08
8.3.240.0160.00616.68
8.3.230.0210.00616.48
8.3.220.0220.00516.51
8.3.210.0190.00616.44
8.3.200.0220.00516.51
8.3.190.0200.00516.61
8.3.180.0220.00616.71
8.3.170.0250.00616.53
8.3.160.0270.00616.74
8.3.150.0260.00716.56
8.3.140.0300.00616.59
8.3.130.0240.00516.48
8.3.120.0230.00816.60
8.3.110.0260.00616.63
8.3.100.0280.00716.57
8.3.90.0260.00816.80
8.3.80.0270.00816.51
8.3.70.0270.00616.44
8.3.60.0270.00616.50
8.3.50.0270.00616.47
8.3.40.0220.00717.87
8.3.30.0220.00617.92
8.3.20.0190.00618.37
8.3.10.0190.00518.42
8.3.00.0140.00618.81
8.2.300.0270.00819.09
8.2.290.0170.00616.88
8.2.280.0180.00616.48
8.2.270.0210.00616.47
8.2.260.0230.00716.60
8.2.250.0220.00716.54
8.2.240.0240.00616.46
8.2.230.0230.00616.52
8.2.220.0230.00816.68
8.2.210.0230.00616.68
8.2.200.0230.00716.48
8.2.190.0240.00616.44
8.2.180.0250.00616.40
8.2.170.0250.00718.00
8.2.160.0240.00718.16
8.2.150.0230.00718.20
8.2.140.0240.00718.28
8.2.130.0230.00718.98
8.2.120.0230.00718.86
8.2.110.0240.00618.84
8.2.100.0210.00718.86
8.2.90.0230.00718.84
8.2.80.0240.00618.80
8.2.70.0230.00718.74
8.2.60.0220.00618.80
8.2.50.0210.00718.81
8.2.40.0210.00718.83
8.2.30.0210.00518.73
8.2.20.0210.00718.79
8.2.10.0220.00618.75
8.2.00.0190.00718.73
8.1.340.0240.01017.50
8.1.330.0220.00616.62
8.1.320.0200.00616.08
8.1.310.0240.00715.96
8.1.300.0220.00616.04
8.1.290.0220.00816.49
8.1.280.0230.00616.42
8.1.270.0250.00518.26
8.1.260.0220.00719.07
8.1.250.0200.00819.03
8.1.240.0210.00618.59
8.1.230.0200.00718.62
8.1.220.0210.00618.58
8.1.210.0210.00818.53
8.1.200.0220.00618.56
8.1.190.0220.00718.49
8.1.180.0220.00718.44
8.1.170.0220.00718.63
8.1.160.0210.00618.58
8.1.150.0200.00718.62
8.1.140.0230.00518.56
8.1.130.0210.00618.57
8.1.120.0190.00818.60
8.1.110.0200.00618.59
8.1.100.0210.00718.71
8.1.90.0210.00718.57
8.1.80.0210.00718.74
8.1.70.0210.00718.65
8.1.60.0210.00818.71
8.1.50.0210.00718.66
8.1.40.0230.00718.70
8.1.30.0230.00718.76
8.1.20.0210.00718.91
8.1.10.0220.00718.64
8.1.00.0210.00718.51
8.0.300.0290.01117.02
8.0.290.0270.00517.05
8.0.280.0310.00417.05
8.0.270.0280.00617.05
8.0.260.0210.01216.94
8.0.250.0290.00817.11
8.0.240.0280.00716.96
8.0.230.0230.01117.05
8.0.220.0310.00916.85
8.0.210.0260.00716.96
8.0.200.0280.00416.82
8.0.190.0240.00917.10
8.0.180.0260.00317.11
8.0.170.0220.00517.04
8.0.160.0320.00417.10
8.0.150.0250.00717.00
8.0.140.0280.00616.93
8.0.130.0260.00617.05
8.0.120.0220.00816.98
8.0.110.0260.00916.75
8.0.100.0230.01216.54
8.0.90.0270.00716.87
8.0.80.0280.00616.90
8.0.70.0250.00816.75
8.0.60.0270.00616.77
8.0.50.0270.00717.01
8.0.30.0340.00116.92
8.0.20.0270.00916.87
8.0.10.0290.00717.16
8.0.00.0290.00517.18
7.4.330.0280.00816.75
7.4.320.0260.00816.61
7.4.300.0250.00716.85
7.4.290.0310.00816.66
7.4.280.0240.00916.85
7.4.270.0240.00816.79
7.4.260.0280.00516.85
7.4.250.0240.00916.53
7.4.240.0210.01216.77
7.4.230.0240.01016.71
7.4.220.0280.00616.73
7.4.210.0250.00816.61
7.4.200.0260.00616.78
7.4.190.0270.00216.83
7.4.180.0210.00516.78
7.4.160.0310.00416.72
7.4.150.0330.00516.45
7.4.140.0260.00716.80
7.4.130.0260.00716.43
7.4.120.0250.00916.45
7.4.110.0280.00716.13
7.4.100.0260.01216.35
7.4.90.0270.00816.54
7.4.80.0270.00716.41
7.4.70.0240.00916.50
7.4.60.0230.00916.41
7.4.50.0270.00716.49
7.4.40.0250.00916.67
7.4.30.0270.00616.48
7.4.20.0280.00516.44
7.4.10.0280.00516.39
7.4.00.0260.00716.48
7.3.330.0210.00516.40
7.3.320.0250.00416.50
7.3.310.0260.00716.49
7.3.300.0260.01016.44
7.3.290.0250.00416.50
7.3.280.0260.00916.46
7.3.270.0240.00716.50
7.3.260.0260.00216.50
7.3.250.0310.00416.14
7.3.240.0220.00816.40
7.3.230.0210.01016.39
7.3.220.0250.00816.31
7.3.210.0230.00816.39
7.3.200.0170.00916.34
7.3.190.0230.00316.49
7.3.180.0200.00916.55
7.3.170.0230.00616.42
7.3.160.0210.00416.34
7.3.150.0180.00716.43
7.3.140.0230.01216.24
7.3.130.0220.01016.32
7.3.120.0240.00816.28
7.3.110.0260.00716.34
7.3.100.0260.00416.32
7.3.90.0260.00516.71
7.3.80.0210.01016.29
7.3.70.0250.00616.55
7.3.60.0230.00816.68
7.3.50.0250.00816.68
7.3.40.0190.01116.62
7.3.30.0260.00416.64
7.3.20.0300.00418.36
7.3.10.0220.00918.05
7.3.00.0260.00718.14
7.2.340.0250.00716.34
7.2.330.0250.00616.47
7.2.320.0220.00916.50
7.2.310.0230.00816.39
7.2.300.0260.00616.34
7.2.290.0290.00516.36
7.2.280.0240.00916.32
7.2.270.0250.01016.30
7.2.260.0290.00316.34
7.2.250.0250.00616.36
7.2.240.0220.01016.32
7.2.230.0230.00816.31
7.2.220.0260.00616.30
7.2.210.0260.00416.34
7.2.200.0180.01016.60
7.2.190.0280.00716.66
7.2.180.0250.00716.58
7.2.170.0250.00616.62
7.2.160.0250.00716.74
7.2.150.0260.00718.35
7.2.140.0190.01318.50
7.2.130.0230.00818.57
7.2.120.0250.00618.57
7.2.110.0320.00618.63
7.2.100.0270.00418.56
7.2.90.0300.00518.27
7.2.80.0340.00718.29
7.2.70.0280.00618.14
7.2.60.0270.00418.53
7.2.50.0250.00818.53
7.2.40.0250.00618.52
7.2.30.0280.00418.46
7.2.20.0230.00718.53
7.2.10.0270.00718.50
7.2.00.0240.00718.64
7.1.330.0220.00817.14
7.1.320.0250.00717.27
7.1.310.0270.00517.36
7.1.300.0240.00517.27
7.1.290.0290.00517.41
7.1.280.0240.00617.24
7.1.270.0260.00717.41
7.1.260.0230.00717.41
7.1.250.0250.00417.30
7.1.240.0240.00617.30
7.1.230.0330.00617.36
7.1.220.0260.00617.52
7.1.210.0220.00717.29
7.1.200.0260.00717.36
7.1.190.0250.00517.38
7.1.180.0270.00817.10
7.1.170.0260.00617.14
7.1.160.0230.00317.25
7.1.150.0210.00717.34
7.1.140.0260.00517.34
7.1.130.0320.00617.23
7.1.120.0190.01117.28
7.1.110.0210.00917.17
7.1.100.0250.00817.10
7.1.90.0260.00417.35
7.1.80.0250.00817.39
7.1.70.0230.00617.17
7.1.60.0260.00717.44
7.1.50.0240.00717.45
7.1.40.0230.00517.14
7.1.30.0220.00717.13
7.1.20.0220.00817.23
7.1.10.0230.00517.33
7.1.00.0200.00717.33
7.0.330.0250.00717.10
7.0.320.0190.01017.09
7.0.310.0250.00717.20
7.0.300.0220.00717.20
7.0.290.0160.00917.15
7.0.280.0220.00717.13
7.0.270.0280.00416.97
7.0.260.0230.00916.84
7.0.250.0280.00617.32
7.0.240.0220.00717.24
7.0.230.0240.00817.15
7.0.220.0250.00517.00
7.0.210.0230.00517.41
7.0.200.0260.00616.77
7.0.190.0210.00717.25
7.0.180.0240.00517.07
7.0.170.0280.00517.36
7.0.160.0290.00516.84
7.0.150.0250.00617.24
7.0.140.0220.00717.32
7.0.130.0280.00417.13
7.0.120.0210.00917.27
7.0.110.0260.00617.12
7.0.100.0230.00617.02
7.0.90.0290.00416.89
7.0.80.0230.00716.92
7.0.70.0250.00817.05
7.0.60.0250.00916.87
7.0.50.0230.00716.77
7.0.40.0260.00617.10
7.0.30.0260.00317.14
7.0.20.0230.00717.06
7.0.10.0210.00717.05
7.0.00.0250.00717.15
5.6.400.0210.00915.90
5.6.390.0200.01215.68
5.6.380.0230.00715.88
5.6.370.0180.01215.72
5.6.360.0240.00715.64
5.6.350.0260.00615.72
5.6.340.0250.00915.68
5.6.330.0260.00515.69
5.6.320.0250.00615.80
5.6.310.0230.00715.74
5.6.300.0240.00615.78
5.6.290.0230.00715.91
5.6.280.0210.00815.73
5.6.270.0240.00515.91
5.6.260.0250.00515.94
5.6.250.0280.00615.81
5.6.240.0230.00715.57
5.6.230.0230.00615.82
5.6.220.0240.00715.80
5.6.210.0230.00715.82
5.6.200.0250.00415.73
5.6.190.0260.01015.95
5.6.180.0240.00716.02
5.6.170.0200.00516.02
5.6.160.0240.00415.89
5.6.150.0250.00515.79
5.6.140.0230.01015.86
5.6.130.0230.00715.88
5.6.120.0210.00415.82
5.6.110.0200.00715.66
5.6.100.0220.00715.83
5.6.90.0240.00715.75
5.6.80.0180.01115.83
5.6.70.0260.00615.95
5.6.60.0230.00915.86
5.6.50.0230.00815.87
5.6.40.0230.00515.67
5.6.30.0200.01015.75
5.6.20.0220.00815.71
5.6.10.0240.00415.71
5.6.00.0230.00715.53
5.5.380.0220.00815.61
5.5.370.0260.00815.69
5.5.360.0240.00415.79
5.5.350.0260.00315.85
5.5.340.0230.00615.53
5.5.330.0230.00615.78
5.5.320.0210.00915.67
5.5.310.0250.00815.67
5.5.300.0200.00815.79
5.5.290.0210.00915.79
5.5.280.0220.00815.85
5.5.270.0230.00615.71
5.5.260.0220.00415.67
5.5.250.0230.00615.79
5.5.240.0230.00615.86
5.5.230.0220.00615.98
5.5.220.0220.00715.39
5.5.210.0200.01115.81
5.5.200.0220.00615.77
5.5.190.0190.01015.72
5.5.180.0190.00815.73
5.5.170.0270.00315.63
5.5.160.0270.00515.73
5.5.150.0250.00415.66
5.5.140.0220.00715.56
5.5.130.0210.00615.51
5.5.120.0200.00515.59
5.5.110.0180.01015.47
5.5.100.0240.00615.55
5.5.90.0240.00515.66
5.5.80.0260.00315.73
5.5.70.0290.00215.75
5.5.60.0240.00515.50
5.5.50.0200.00815.50
5.5.40.0240.00615.75
5.5.30.0200.00915.75
5.5.20.0160.00815.68
5.5.10.0190.00715.68
5.5.00.0220.00815.72
5.4.450.0140.00514.66
5.4.440.0250.00414.66
5.4.430.0180.00714.66
5.4.420.0230.00414.66
5.4.410.0160.00314.66
5.4.400.0120.00614.66
5.4.390.0200.00614.66
5.4.380.0180.00314.66
5.4.370.0160.00714.66
5.4.360.0210.00214.66
5.4.350.0170.00614.66
5.4.340.0190.00714.66
5.4.330.0170.00514.66
5.4.320.0180.00414.66
5.4.310.0150.00714.66
5.4.300.0200.00214.66
5.4.290.0140.00814.66
5.4.280.0160.00714.66
5.4.270.0200.00414.66
5.4.260.0190.00414.66
5.4.250.0160.00614.66
5.4.240.0180.00514.66
5.4.230.0210.00414.66
5.4.220.0200.00314.66
5.4.210.0170.00514.66
5.4.200.0140.00814.66
5.4.190.0170.00614.66
5.4.180.0190.00414.66
5.4.170.0210.00214.66
5.4.160.0170.00314.66
5.4.150.0180.00614.66
5.4.140.0190.00414.66
5.4.130.0180.00414.66
5.4.120.0180.00714.66
5.4.110.0210.00514.66
5.4.100.0170.00414.66
5.4.90.0140.00414.66
5.4.80.0130.00514.66
5.4.70.0140.00414.66
5.4.60.0140.00414.66
5.4.50.0130.00414.66
5.4.40.0160.00514.66
5.4.30.0150.00814.66
5.4.20.0170.00514.66
5.4.10.0180.00414.66
5.4.00.0150.00714.66
5.3.290.0190.00614.66
5.3.280.0160.00714.66
5.3.270.0230.00514.66
5.3.260.0150.00814.66
5.3.250.0190.00414.66
5.3.240.0160.00714.66
5.3.230.0160.00514.66
5.3.220.0160.00814.66
5.3.210.0170.00614.66
5.3.200.0190.00414.66
5.3.190.0170.00714.66
5.3.180.0150.00714.66
5.3.170.0180.00514.66
5.3.160.0190.00414.66
5.3.150.0180.00414.66
5.3.140.0170.00714.66
5.3.130.0230.00414.66
5.3.120.0180.00814.66
5.3.110.0160.00514.66
5.3.100.0170.00614.66
5.3.90.0190.00314.66
5.3.80.0160.00714.66
5.3.70.0180.00514.66
5.3.60.0140.00514.66
5.3.50.0140.00414.66
5.3.40.0180.00514.66
5.3.30.0140.00814.66
5.3.20.0200.00514.66
5.3.10.0170.00514.66
5.3.00.0170.00514.66
5.2.170.0120.00714.66
5.2.160.0160.00614.66
5.2.150.0130.00414.66
5.2.140.0130.00314.66
5.2.130.0110.00414.66
5.2.120.0070.00614.66
5.2.110.0070.00214.66
5.2.100.0060.00214.66
5.2.90.0100.00314.66
5.2.80.0110.00314.66
5.2.70.0140.00514.66
5.2.60.0130.00614.66
5.2.50.0130.00614.66
5.2.40.0140.00414.66
5.2.30.0120.00614.66
5.2.20.0120.00614.66
5.2.10.0130.00414.66
5.2.00.0150.00514.66
5.1.60.0100.00814.66
5.1.50.0110.00414.66
5.1.40.0140.00314.66
5.1.30.0110.00414.66
5.1.20.0120.00514.66
5.1.10.0140.00314.66
5.1.00.0140.00214.66
5.0.50.0080.00614.66
5.0.40.0100.00414.66
5.0.30.0110.00414.66
5.0.20.0100.00414.66
5.0.10.0110.00314.66
5.0.00.0100.00414.66
4.4.90.0060.00314.66
4.4.80.0060.00414.66
4.4.70.0080.00214.66
4.4.60.0090.00114.66
4.4.50.0070.00214.66
4.4.40.0090.00114.66
4.4.30.0070.00214.66
4.4.20.0070.00214.66
4.4.10.0060.00314.66
4.4.00.0060.00314.66
4.3.110.0060.00314.66
4.3.100.0060.00314.66
4.3.90.0070.00214.66
4.3.80.0070.00214.66
4.3.70.0070.00214.66
4.3.60.0080.00114.66
4.3.50.0080.00114.66
4.3.40.0090.00114.66
4.3.30.0060.00214.66
4.3.20.0050.00314.66
4.3.10.0060.00114.66
4.3.00.0040.00414.66

preferences:
68.84 ms | 2712 KiB | 5 Q