3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all five below and click blue 'eval();' button below textarea. * * ------------------ */ $caseNumber = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $qty = -1; /* ------------------ */ if ($caseNumber < 0 || $unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $qty < 0) { echo "Fill in details"; return; } $unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed ); $clientSeed = preg_replace( "/\r|\n/", "", $clientSeed ); function stringToInt32($seed) { $groups = str_split((string)$seed, 4); $groups = array_map(function ($g) { return unpack('C*', $g); }, $groups); $groups = array_filter($groups, function ($g) { return count($g) === 4; }); $result = array_map(function ($group) { return array_reduce($group, function ($acc, $cur) { return ($acc << 4) | $cur; }, 0); }, $groups); return array_reduce($result, function ($acc, $cur) { return ($acc ^ $cur); }, 0); } $serverSeedInt = stringToInt32($unhashedServerSeed); $clientSeedInt = stringToInt32($clientSeed); $seed = $serverSeedInt ^ $clientSeedInt ^ (int)$caseNumber ^ (int)$nonce; mt_srand($seed, MT_RAND_MT19937); $result = mt_rand(1, $qty); echo "Seed: $seed\n"; echo "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.0300.00816.95
8.5.20.0340.00716.58
8.5.10.0330.00816.55
8.5.00.0260.00816.68
8.4.180.0220.00919.47
8.4.170.0350.00819.52
8.4.160.0340.00919.57
8.4.150.0320.01119.59
8.4.140.0350.01217.43
8.4.130.0380.00817.51
8.4.120.0360.00917.57
8.4.110.0340.00917.61
8.4.100.0370.01017.76
8.4.90.0390.00817.68
8.4.80.0380.01117.66
8.4.70.0360.00918.02
8.4.60.0370.00917.76
8.4.50.0390.01117.70
8.4.40.0390.00817.54
8.4.30.0380.01017.51
8.4.20.0340.00917.48
8.4.10.0340.00917.45
8.3.300.0310.01018.31
8.3.290.0380.00918.11
8.3.280.0310.00818.35
8.3.270.0380.00716.48
8.3.260.0370.00916.55
8.3.250.0350.00816.53
8.3.240.0310.00916.74
8.3.230.0330.00716.56
8.3.220.0370.00816.57
8.3.210.0340.00916.82
8.3.200.0350.00716.89
8.3.190.0300.00716.81
8.3.180.0280.00717.01
8.3.170.0340.00816.65
8.3.160.0320.00716.66
8.3.150.0290.00816.61
8.3.140.0320.00816.66
8.3.130.0300.00516.65
8.3.120.0260.00616.64
8.3.110.0290.00717.05
8.3.100.0330.00917.08
8.3.90.0350.00817.75
8.3.80.0320.00917.73
8.3.70.0330.00717.73
8.3.60.0330.00817.76
8.3.50.0330.00717.70
8.3.40.0320.00818.50
8.3.30.0260.00718.47
8.3.20.0250.00818.95
8.3.10.0270.00919.04
8.3.00.0200.00719.12
8.2.300.0350.00518.02
8.2.290.0290.00616.55
8.2.280.0260.00716.70
8.2.270.0310.00816.58
8.2.260.0270.01016.54
8.2.250.0260.00816.69
8.2.240.0250.00916.60
8.2.230.0280.00716.98
8.2.220.0260.00717.03
8.2.210.0260.00617.68
8.2.200.0270.00817.67
8.2.190.0310.00617.73
8.2.180.0260.00917.72
8.2.170.0310.00818.70
8.2.160.0280.00618.61
8.2.150.0310.00719.03
8.2.140.0290.00719.02
8.2.130.0310.00719.07
8.2.120.0300.00719.00
8.2.110.0270.00619.41
8.2.100.0270.00819.19
8.2.90.0280.00718.80
8.2.80.0260.00818.72
8.2.70.0270.00721.29
8.2.60.0260.00620.82
8.2.50.0230.00820.88
8.2.40.0220.00620.68
8.2.30.0210.00720.59
8.2.20.0200.00620.57
8.2.10.0230.00520.58
8.2.00.0220.00620.50
8.1.340.0370.00817.46
8.1.330.0300.00916.17
8.1.320.0300.00716.48
8.1.310.0290.00716.32
8.1.300.0310.00716.24
8.1.290.0310.00817.48
8.1.280.0280.00717.46
8.1.270.0260.00818.88
8.1.260.0260.00818.90
8.1.250.0260.00718.91
8.1.240.0240.00618.85
8.1.230.0220.00818.84
8.1.220.0220.00618.60
8.1.210.0210.00918.76
8.1.200.0230.00621.12
8.1.190.0210.00720.68
8.1.180.0210.00720.55
8.1.170.0200.00620.49
8.1.160.0190.00620.47
8.1.150.0190.00620.55
8.1.140.0200.00520.35
8.1.130.0180.00619.99
8.1.120.0170.00619.82
8.1.110.0180.00519.75
8.1.100.0180.00519.68
8.1.90.0180.00519.73
8.1.80.0160.00619.43
8.1.70.0170.00619.48
8.1.60.0180.00619.54
8.1.50.0170.00619.50
8.1.40.0160.00719.41
8.1.30.0180.00619.52
8.1.20.0170.00619.46
8.1.10.0170.00619.31
8.1.00.0160.00619.27
8.0.300.0240.00718.04
8.0.290.0250.00620.68
8.0.280.0200.00619.95
8.0.270.0200.00619.90
8.0.260.0190.00619.61
8.0.250.0170.00519.41
8.0.240.0170.00519.25
8.0.230.0180.00519.30
8.0.220.0180.00519.24
8.0.210.0150.00618.98
8.0.200.0160.00519.01
8.0.190.0150.00619.01
8.0.180.0170.00419.00
8.0.170.0160.00618.97
8.0.160.0160.00418.89
8.0.150.0160.00618.80
8.0.140.0160.00618.77
8.0.130.0170.00518.80
8.0.120.0150.00618.78
8.0.110.0150.00518.74
8.0.100.0150.00618.65
8.0.90.0170.00518.74
8.0.80.0160.00618.72
8.0.70.0160.00618.65
8.0.60.0150.00618.69
8.0.50.0150.00518.68
8.0.30.0140.00718.37
8.0.20.0130.00718.36
8.0.10.0140.00618.39
8.0.00.0130.00618.53
7.4.330.0160.00519.04
7.4.320.0180.00619.03
7.4.300.0160.00618.81
7.4.290.0170.00518.82
7.4.280.0170.00518.69
7.4.270.0160.00518.61
7.4.260.0160.00518.62
7.4.250.0150.00618.62
7.4.240.0150.00518.56
7.4.230.0150.00518.52
7.4.220.0140.00518.56
7.4.210.0140.00518.46
7.4.200.0140.00518.51
7.4.190.0150.00518.46
7.4.180.0140.00618.50
7.4.160.0130.00718.17
7.4.150.0140.00618.03
7.4.140.0130.00617.95
7.4.130.0130.00617.92
7.4.120.0130.00617.85
7.4.110.0150.00617.78
7.4.100.0130.00717.77
7.4.90.0140.00617.68
7.4.80.0140.00617.70
7.4.70.0130.00717.69
7.4.60.0140.00717.69
7.4.50.0130.00717.57
7.4.40.0130.00717.50
7.4.30.0130.00717.51
7.4.20.0120.00717.45
7.4.10.0130.00717.40
7.4.00.0110.00817.35
7.3.330.0160.00518.43
7.3.320.0160.00518.40
7.3.310.0160.00518.35
7.3.300.0160.00518.35
7.3.290.0160.00418.30
7.3.280.0150.00518.20
7.3.270.0150.00517.82
7.3.260.0140.00617.81
7.3.250.0140.00617.78
7.3.240.0140.00617.68
7.3.230.0140.00617.63
7.3.220.0150.00617.55
7.3.210.0150.00617.50
7.3.200.0140.00617.55
7.3.190.0130.00717.53
7.3.180.0140.00717.52
7.3.170.0150.00617.43
7.3.160.0130.00817.37
7.3.150.0130.00817.33
7.3.140.0130.00717.31
7.3.130.0130.00717.23
7.3.120.0130.00717.13
7.3.110.0130.00717.10
7.3.100.0130.00717.08
7.3.90.0130.00717.22
7.3.80.0130.00717.13
7.3.70.0130.00717.19
7.3.60.0120.00817.21
7.3.50.0130.00717.23
7.3.40.0130.00717.18
7.3.30.0130.00717.22
7.3.20.0140.00717.73
7.3.10.0130.00717.70
7.3.00.0150.00717.68
7.2.340.0160.00717.74
7.2.330.0160.00717.61
7.2.320.0160.00717.63
7.2.310.0150.00717.62
7.2.300.0150.00717.63
7.2.290.0140.00717.50
7.2.280.0150.00817.46
7.2.270.0150.00717.44
7.2.260.0150.00717.36
7.2.250.0140.00817.25
7.2.240.0140.00817.25
7.2.230.0150.00717.26
7.2.220.0140.00817.27
7.2.210.0130.00817.24
7.2.200.0150.00817.33
7.2.190.0150.00817.32
7.2.180.0150.00817.33
7.2.170.0140.00817.34
7.2.160.0140.00817.40
7.2.150.0160.00717.99
7.2.140.0150.00718.00
7.2.130.0170.00818.01
7.2.120.0160.00718.00
7.2.110.0160.00818.00
7.2.100.0170.00718.01
7.2.90.0180.00817.97
7.2.80.0150.00717.98
7.2.70.0170.00717.99
7.2.60.0150.00817.98
7.2.50.0160.00817.98
7.2.40.0150.00718.02
7.2.30.0150.00818.01
7.2.20.0160.00718.02
7.2.10.0160.00718.04
7.2.00.0150.00818.00

preferences:
46.52 ms | 1519 KiB | 5 Q