3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Case Battle Fairness | Round Validation $serverSeed = ''; // Server seed $eosBlockSeed = ''; // EOS Block Seed /* * This is the round number, where 1 round is one case opened. If the battle has 10 cases, * this means there are 10 rounds - 1-10. * IMPORTANT: If it's the tiebreaker round, it will always be totalRounds + 1 * because the tiebreaker is considered as one additional round. If you have 2 cases * which results in 2 rounds, the tiebreaker roundNumber is 3 because it's total (2) + 1. */ $roundNumber = -1; /* * Player position that we want to validate the roll for. * For example, if you want to validate your own roll and you were holding * the 3rd position from left to right, then playerPosition will be 3. */ $playerPosition = -1; // The Player Position (1 to 4) // Update this to true if you are validating a tiebreaker result. $isTiebreaker = false; /* * Case Ticket's Quantity, by default it's 100,000 * We only change this if there's a case that has different ticket distribution. * Right now, all cases use 100,000 by default. * IMPORTANT: If it's the tiebreaker round, this will be number of players participating on the tiebreaker. * For example, if two players are participating on a tiebreaker the ticketQuantity is 2. */ $ticketQuantity = 100000; /* ------------------ */ if ($serverSeed == '' || $eosBlockSeed == '' || $roundNumber < 0 || $playerPosition < 1 || $playerPosition > 4 || $ticketQuantity <= 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, ]; } $serverSeed = preg_replace("/\r|\n/", "", $serverSeed); $eosBlockSeed = preg_replace("/\r|\n/", "", $eosBlockSeed); if ($isTiebreaker) { $stringToHash = "$serverSeed-$eosBlockSeed-$roundNumber"; } else { $stringToHash = "$serverSeed-$eosBlockSeed-$roundNumber-$playerPosition"; } $result = getProvablyFairResult($stringToHash, $ticketQuantity); 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.0090.00820.17
8.5.10.0250.00916.60
8.5.00.0200.01017.76
8.4.170.0110.01221.92
8.4.160.0270.00820.90
8.4.150.0220.00717.72
8.4.140.0290.00817.64
8.4.130.0260.00817.73
8.4.120.0230.00720.94
8.4.110.0280.00918.09
8.4.100.0320.00718.05
8.4.90.0300.00818.00
8.4.80.0290.00818.00
8.4.70.0320.00917.92
8.4.60.0310.00817.75
8.4.50.0320.00817.79
8.4.40.0320.00817.65
8.4.30.0360.00817.65
8.4.20.0310.00917.55
8.4.10.0310.00617.61
8.3.300.0050.00518.39
8.3.290.0260.00919.09
8.3.280.0250.00918.96
8.3.270.0280.00816.74
8.3.260.0290.00816.56
8.3.250.0290.00816.70
8.3.240.0260.00817.18
8.3.230.0310.00716.42
8.3.220.0260.00616.83
8.3.210.0290.00816.60
8.3.200.0280.00716.44
8.3.190.0260.00616.79
8.3.180.0250.00616.67
8.3.170.0300.00716.67
8.3.160.0310.00716.60
8.3.150.0300.00816.60
8.3.140.0290.00716.63
8.3.130.0260.00516.54
8.3.120.0260.00616.72
8.3.110.0240.00516.80
8.3.100.0270.00716.62
8.3.90.0300.00617.33
8.3.80.0290.00716.66
8.3.70.0300.00616.62
8.3.60.0280.00616.67
8.3.50.0280.00616.61
8.3.40.0270.00718.03
8.3.30.0230.00717.87
8.3.20.0240.00818.08
8.3.10.0250.00718.15
8.3.00.0220.00817.90
8.2.300.0290.01118.79
8.2.290.0270.00517.07
8.2.280.0250.00717.05
8.2.270.0290.00716.50
8.2.260.0270.00716.45
8.2.250.0250.00716.67
8.2.240.0240.00616.61
8.2.230.0250.00716.92
8.2.220.0230.00716.96
8.2.210.0230.00717.10
8.2.200.0230.00616.62
8.2.190.0260.00716.52
8.2.180.0260.00816.47
8.2.170.0300.00718.16
8.2.160.0290.00818.06
8.2.150.0270.00818.00
8.2.140.0280.00818.03
8.2.130.0250.00618.03
8.2.120.0280.00518.04
8.2.110.0260.00818.04
8.2.100.0260.00817.96
8.2.90.0270.00818.06
8.2.80.0260.00717.97
8.2.70.0260.00717.91
8.2.60.0250.00718.02
8.2.50.0260.00717.94
8.2.40.0270.00817.90
8.2.30.0250.00617.89
8.2.20.0240.00717.91
8.2.10.0240.00717.92
8.2.00.0260.00717.91
8.1.340.0220.01118.98
8.1.330.0270.00716.82
8.1.320.0280.00916.13
8.1.310.0250.00916.10
8.1.300.0260.00616.26
8.1.290.0240.00917.15
8.1.280.0270.00716.88
8.1.270.0250.00618.06
8.1.260.0220.00818.02
8.1.250.0250.00618.03
8.1.240.0230.00717.80
8.1.230.0210.00717.82
8.1.220.0220.00717.73
8.1.210.0250.00817.66
8.1.200.0260.00617.67
8.1.190.0210.00717.69
8.1.180.0250.00817.64
8.1.170.0240.00617.69
8.1.160.0250.00717.73
8.1.150.0210.00717.80
8.1.140.0250.00617.71
8.1.130.0230.00817.79
8.1.120.0260.00717.81
8.1.110.0250.00817.78
8.1.100.0240.00717.86
8.1.90.0230.00617.75
8.1.80.0230.00817.78
8.1.70.0240.00717.75
8.1.60.0260.00517.90
8.1.50.0230.00717.86
8.1.40.0240.00717.86
8.1.30.0230.00817.90
8.1.20.0250.00817.95
8.1.10.0260.00817.77
8.1.00.0240.00817.67
8.0.300.0270.00717.06
8.0.290.0270.00917.23
8.0.280.0240.01017.03
8.0.270.0290.00616.88
8.0.260.0280.00717.01
8.0.250.0300.00816.98
8.0.240.0330.00216.98
8.0.230.0290.00717.03
8.0.220.0260.00916.91
8.0.210.0260.00916.80
8.0.200.0270.00717.11
8.0.190.0290.00816.97
8.0.180.0310.00617.11
8.0.170.0320.00517.00
8.0.160.0260.00917.02
8.0.150.0290.00916.71
8.0.140.0350.00716.63
8.0.130.0210.01416.86
8.0.120.0260.01016.91
8.0.110.0260.01116.69
8.0.100.0300.00816.89
8.0.90.0330.00516.65
8.0.80.0310.00616.91
8.0.70.0290.00716.95
8.0.60.0280.00816.93
8.0.50.0280.00716.77
8.0.30.0260.00816.87
8.0.20.0260.00816.86
8.0.10.0290.00517.04
8.0.00.0300.00417.21
7.4.330.0240.01016.84
7.4.320.0240.01016.74
7.4.300.0310.00416.87
7.4.290.0300.00816.62
7.4.280.0290.00616.82
7.4.270.0320.00816.77
7.4.260.0250.01016.84
7.4.250.0280.00816.73
7.4.240.0260.00916.76
7.4.230.0270.00616.73
7.4.220.0260.00816.78
7.4.210.0280.00716.64
7.4.200.0290.01016.79
7.4.190.0290.00616.83
7.4.180.0290.00816.58
7.4.160.0310.00616.89
7.4.150.0310.00716.75
7.4.140.0320.00716.45
7.4.130.0270.01016.31
7.4.120.0270.01116.40
7.4.110.0360.00716.49
7.4.100.0250.01216.73
7.4.90.0350.00416.47
7.4.80.0260.01116.55
7.4.70.0240.01116.61
7.4.60.0250.00816.59
7.4.50.0260.00816.67
7.4.40.0290.00616.63
7.4.30.0260.00816.38
7.4.20.0270.00816.48
7.4.10.0320.00616.42
7.4.00.0300.00616.52
7.3.330.0230.00916.50
7.3.320.0240.00916.31
7.3.310.0250.00816.09
7.3.300.0240.00716.56
7.3.290.0250.00716.51
7.3.280.0320.00816.43
7.3.270.0190.01017.02
7.3.260.0250.00716.50
7.3.250.0220.01016.56
7.3.240.0250.00716.50
7.3.230.0360.00416.36
7.3.220.0270.01216.47
7.3.210.0280.00516.34
7.3.200.0180.01016.46
7.3.190.0230.01116.38
7.3.180.0280.00916.29
7.3.170.0250.01316.18
7.3.160.0330.00616.33
7.3.150.0280.00716.42
7.3.140.0280.00816.16
7.3.130.0270.00616.28
7.3.120.0270.00816.42
7.3.110.0220.01016.18
7.3.100.0310.00316.22
7.3.90.0290.00516.67
7.3.80.0270.00716.24
7.3.70.0260.00616.41
7.3.60.0290.00516.68
7.3.50.0270.00516.41
7.3.40.0240.00916.68
7.3.30.0230.00916.72
7.3.20.0290.00618.41
7.3.10.0290.00618.11
7.3.00.0290.00618.33
7.2.340.0220.01016.21
7.2.330.0290.00716.49
7.2.320.0220.00716.28
7.2.310.0240.01016.59
7.2.300.0270.00716.41
7.2.290.0240.00916.54
7.2.280.0280.00516.37
7.2.270.0260.00816.44
7.2.260.0310.00716.14
7.2.250.0260.00716.46
7.2.240.0260.00716.49
7.2.230.0290.00416.54
7.2.220.0250.00916.30
7.2.210.0250.00816.30
7.2.200.0240.00716.63
7.2.190.0230.01016.71
7.2.180.0320.00816.50
7.2.170.0250.00716.71
7.2.160.0250.00716.60
7.2.150.0290.00618.44
7.2.140.0270.00818.42
7.2.130.0270.00818.63
7.2.120.0240.01018.45
7.2.110.0300.00718.56
7.2.100.0260.00918.63
7.2.90.0330.00718.32
7.2.80.0260.01018.45
7.2.70.0230.01118.52
7.2.60.0250.00918.35
7.2.50.0280.00618.52
7.2.40.0280.00818.55
7.2.30.0260.00918.52
7.2.20.0270.00918.53
7.2.10.0310.00518.48
7.2.00.0250.01018.54
7.1.330.0270.00717.39
7.1.320.0270.00717.28
7.1.310.0250.00817.33
7.1.300.0250.00817.09
7.1.290.0280.00717.40
7.1.280.0280.00717.29
7.1.270.0340.00317.09
7.1.260.0320.00717.20
7.1.250.0290.00917.28
7.1.240.0300.00417.23
7.1.230.0270.00717.20
7.1.220.0250.00817.06
7.1.210.0250.00817.42
7.1.200.0250.00717.43
7.1.190.0220.01117.40
7.1.180.0250.00617.24
7.1.170.0230.00917.18
7.1.160.0280.00517.07
7.1.150.0240.00817.13
7.1.140.0260.00617.36
7.1.130.0270.00517.36
7.1.120.0320.00717.39
7.1.110.0280.00517.29
7.1.100.0270.00617.02
7.1.90.0250.00717.34
7.1.80.0240.00817.11
7.1.70.0340.00416.77
7.1.60.0260.00717.37
7.1.50.0280.00517.45
7.1.40.0300.00517.39
7.1.30.0280.00817.27
7.1.20.0280.00817.14
7.1.10.0270.00817.56
7.1.00.0250.00717.35
7.0.330.0250.00817.09
7.0.320.0240.00817.09
7.0.310.0290.00717.28
7.0.300.0270.00516.98
7.0.290.0280.00517.16
7.0.280.0260.00817.09
7.0.270.0260.00517.08
7.0.260.0270.00617.13
7.0.250.0250.00817.32
7.0.240.0270.00617.14
7.0.230.0270.00517.05
7.0.220.0230.01317.25
7.0.210.0280.00417.35
7.0.200.0220.01117.05
7.0.190.0250.00817.35
7.0.180.0300.00517.48
7.0.170.0260.00617.17
7.0.160.0250.00716.95
7.0.150.0300.00317.14
7.0.140.0240.00816.95
7.0.130.0260.00617.11
7.0.120.0270.00717.10
7.0.110.0270.00817.07
7.0.100.0240.00817.23
7.0.90.0290.00516.91
7.0.80.0270.00616.92
7.0.70.0240.01016.93
7.0.60.0230.01016.92
7.0.50.0310.00817.00
7.0.40.0310.00717.05
7.0.30.0220.01117.15
7.0.20.0280.00417.12
7.0.10.0230.00917.18
7.0.00.0270.00517.00
5.6.400.0280.00315.91
5.6.390.0210.01115.91
5.6.380.0270.00515.91
5.6.370.0260.00615.91
5.6.360.0220.01115.91
5.6.350.0290.00315.91
5.6.340.0270.00915.91
5.6.330.0230.00815.91
5.6.320.0280.00615.91
5.6.310.0270.00815.91
5.6.300.0290.00715.91
5.6.290.0250.01115.91
5.6.280.0270.00615.91
5.6.270.0270.00715.91
5.6.260.0280.00615.91
5.6.250.0270.00515.91
5.6.240.0260.00515.91
5.6.230.0230.00815.91
5.6.220.0230.00716.00
5.6.210.0240.00715.99
5.6.200.0230.00715.98
5.6.190.0220.01115.97
5.6.180.0250.00615.91
5.6.170.0260.00515.91
5.6.160.0250.00615.96
5.6.150.0250.00615.96
5.6.140.0220.00815.91
5.6.130.0230.00815.91
5.6.120.0250.00515.91
5.6.110.0270.00615.91
5.6.100.0240.00715.91
5.6.90.0270.00415.91
5.6.80.0230.00715.91
5.6.70.0240.00915.91
5.6.60.0290.00615.91
5.6.50.0220.00815.91
5.6.40.0220.00915.91
5.6.30.0290.00515.91
5.6.20.0240.00515.91
5.6.10.0250.00615.91
5.6.00.0250.00515.91
5.5.380.0250.00615.91
5.5.370.0260.00515.91
5.5.360.0260.00515.91
5.5.350.0220.00915.91
5.5.340.0280.00515.91
5.5.330.0240.00815.91
5.5.320.0260.00515.91
5.5.310.0240.00815.91
5.5.300.0240.00715.91
5.5.290.0230.00815.91
5.5.280.0230.00715.91
5.5.270.0260.00515.91
5.5.260.0250.00715.91
5.5.250.0300.00615.91
5.5.240.0250.00515.91
5.5.230.0250.00615.91
5.5.220.0210.00915.91
5.5.210.0240.00715.91
5.5.200.0260.00615.91
5.5.190.0250.00815.91
5.5.180.0230.00615.91
5.5.170.0270.00515.91
5.5.160.0250.00615.91
5.5.150.0250.00415.91
5.5.140.0260.00415.91
5.5.130.0250.00515.91
5.5.120.0260.00415.91
5.5.110.0250.00515.91
5.5.100.0200.01015.91
5.5.90.0230.00715.91
5.5.80.0250.00415.91
5.5.70.0260.00315.91
5.5.60.0210.00815.91
5.5.50.0230.01015.91
5.5.40.0230.00615.91
5.5.30.0220.00815.91
5.5.20.0220.00815.91
5.5.10.0230.00615.91
5.5.00.0250.00415.91
5.4.450.0200.00315.91
5.4.440.0190.00415.91
5.4.430.0140.01015.91
5.4.420.0200.00515.91
5.4.410.0210.00515.91
5.4.400.0210.00915.91
5.4.390.0190.00615.91
5.4.380.0180.00615.91
5.4.370.0170.00215.91
5.4.360.0210.00415.91
5.4.350.0190.00515.91
5.4.340.0220.00415.91
5.4.330.0170.00815.91
5.4.320.0190.00715.91
5.4.310.0230.00215.91
5.4.300.0170.00715.91
5.4.290.0170.00715.91
5.4.280.0180.00515.91
5.4.270.0190.00515.91
5.4.260.0200.00715.91
5.4.250.0200.00315.91
5.4.240.0180.00515.91
5.4.230.0220.00415.91
5.4.220.0210.00315.91
5.4.210.0200.00515.91
5.4.200.0190.00515.91
5.4.190.0200.00515.91
5.4.180.0200.00315.91
5.4.170.0190.00515.91
5.4.160.0190.00615.91
5.4.150.0210.00315.91
5.4.140.0180.00615.91
5.4.130.0180.00515.91
5.4.120.0180.00615.91
5.4.110.0190.00615.91
5.4.100.0200.00315.91
5.4.90.0150.00815.91
5.4.80.0200.00515.91
5.4.70.0170.00715.91
5.4.60.0170.00715.91
5.4.50.0180.00715.91
5.4.40.0180.00615.91
5.4.30.0210.00615.91
5.4.20.0170.00615.91
5.4.10.0180.00515.91
5.4.00.0180.00715.91
5.3.290.0220.00615.91
5.3.280.0190.00615.91
5.3.270.0210.00515.91
5.3.260.0150.00915.91
5.3.250.0170.00815.91
5.3.240.0200.00515.91
5.3.230.0150.00815.91
5.3.220.0200.00315.91
5.3.210.0170.00715.91
5.3.200.0190.00615.91
5.3.190.0170.00815.91
5.3.180.0190.00515.91
5.3.170.0180.00615.91
5.3.160.0190.00615.91
5.3.150.0170.00815.91
5.3.140.0200.00615.91
5.3.130.0210.00715.91
5.3.120.0200.00715.91
5.3.110.0240.00315.91
5.3.100.0190.00715.91
5.3.90.0180.00615.91
5.3.80.0200.00515.91
5.3.70.0160.00715.91
5.3.60.0180.00615.91
5.3.50.0160.00815.91
5.3.40.0210.00515.91
5.3.30.0170.00715.91
5.3.20.0170.00615.91
5.3.10.0200.00715.91
5.3.00.0190.00415.91
5.2.170.0160.00515.91
5.2.160.0140.00515.91
5.2.150.0140.00515.91
5.2.140.0150.00515.91
5.2.130.0130.00615.91
5.2.120.0100.00915.91
5.2.110.0170.00315.91
5.2.100.0150.00415.91
5.2.90.0140.00615.91
5.2.80.0160.00315.91
5.2.70.0150.00415.91
5.2.60.0120.00715.91
5.2.50.0150.00315.91
5.2.40.0130.00615.91
5.2.30.0120.00715.91
5.2.20.0140.00715.91
5.2.10.0140.00515.91
5.2.00.0120.00615.91
5.1.60.0130.00415.91
5.1.50.0110.00615.91
5.1.40.0130.00515.91
5.1.30.0140.00315.91
5.1.20.0130.00415.91
5.1.10.0140.00315.91
5.1.00.0110.00615.91
5.0.50.0110.00415.91
5.0.40.0090.00815.91
5.0.30.0130.00615.91
5.0.20.0100.00515.91
5.0.10.0090.00615.91
5.0.00.0120.00315.91
4.4.90.0060.00415.91
4.4.80.0070.00315.91
4.4.70.0070.00215.91
4.4.60.0060.00415.91
4.4.50.0100.00015.91
4.4.40.0080.00215.91
4.4.30.0080.00315.91
4.4.20.0080.00315.91
4.4.10.0080.00215.91
4.4.00.0070.00315.91
4.3.110.0080.00215.91
4.3.100.0070.00215.91
4.3.90.0060.00315.91
4.3.80.0060.00315.91
4.3.70.0070.00215.91
4.3.60.0060.00315.91
4.3.50.0080.00115.91
4.3.40.0050.00415.91
4.3.30.0070.00115.91
4.3.20.0060.00215.91
4.3.10.0060.00215.91
4.3.00.0060.00215.91

preferences:
95.5 ms | 403 KiB | 5 Q