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.90.0080.00416.81
8.5.80.0290.01016.72
8.5.70.0160.00416.64
8.5.60.0170.00416.61
8.5.50.0050.00316.62
8.5.40.0130.00516.82
8.5.30.0250.00716.82
8.5.20.0270.00716.53
8.5.10.0280.00716.57
8.5.00.0180.00716.66
8.4.230.0210.00619.24
8.4.220.0180.00519.18
8.4.210.0190.00819.32
8.4.200.0200.00719.44
8.4.190.0160.00719.48
8.4.180.0200.00919.48
8.4.170.0280.00719.57
8.4.160.0290.00719.53
8.4.150.0260.01019.55
8.4.140.0290.01017.44
8.4.130.0320.00817.49
8.4.120.0310.00817.55
8.4.110.0300.00817.61
8.4.100.0340.00917.73
8.4.90.0350.00717.65
8.4.80.0350.01017.59
8.4.70.0330.00917.95
8.4.60.0340.00817.75
8.4.50.0360.01017.66
8.4.40.0370.00817.52
8.4.30.0360.00917.51
8.4.20.0330.00917.48
8.4.10.0320.00917.46
8.3.330.0150.00418.31
8.3.320.0160.00218.13
8.3.310.0200.00318.32
8.3.300.0250.00918.23
8.3.290.0290.00918.08
8.3.280.0250.00818.25
8.3.270.0320.00716.54
8.3.260.0320.00816.54
8.3.250.0300.00816.58
8.3.240.0280.00816.73
8.3.230.0300.00616.57
8.3.220.0340.00716.55
8.3.210.0310.00916.80
8.3.200.0320.00716.84
8.3.190.0280.00616.77
8.3.180.0270.00616.94
8.3.170.0320.00816.64
8.3.160.0310.00716.65
8.3.150.0280.00716.60
8.3.140.0310.00716.63
8.3.130.0290.00516.64
8.3.120.0250.00616.64
8.3.110.0280.00617.00
8.3.100.0310.00917.05
8.3.90.0340.00817.66
8.3.80.0310.00817.65
8.3.70.0320.00717.67
8.3.60.0320.00817.68
8.3.50.0320.00717.61
8.3.40.0310.00818.44
8.3.30.0250.00718.43
8.3.20.0240.00818.86
8.3.10.0260.00818.95
8.3.00.0200.00719.03
8.2.330.0220.00517.81
8.2.320.0160.00418.05
8.2.310.0140.00417.60
8.2.300.0270.00617.99
8.2.290.0260.00516.54
8.2.280.0250.00716.70
8.2.270.0300.00816.59
8.2.260.0250.00916.52
8.2.250.0250.00716.68
8.2.240.0240.00816.60
8.2.230.0270.00716.94
8.2.220.0250.00616.98
8.2.210.0250.00617.59
8.2.200.0270.00817.58
8.2.190.0300.00617.64
8.2.180.0250.00917.62
8.2.170.0290.00718.65
8.2.160.0270.00618.55
8.2.150.0300.00718.96
8.2.140.0280.00718.94
8.2.130.0300.00718.98
8.2.120.0290.00718.93
8.2.110.0260.00619.32
8.2.100.0260.00819.12
8.2.90.0270.00718.76
8.2.80.0250.00818.67
8.2.70.0260.00721.15
8.2.60.0260.00620.71
8.2.50.0230.00820.77
8.2.40.0220.00620.58
8.2.30.0200.00720.49
8.2.20.0200.00620.47
8.2.10.0220.00520.49
8.2.00.0210.00620.41
8.1.340.0310.00717.39
8.1.330.0270.00716.14
8.1.320.0280.00716.43
8.1.310.0280.00716.31
8.1.300.0300.00716.24
8.1.290.0290.00717.39
8.1.280.0270.00617.37
8.1.270.0250.00818.79
8.1.260.0250.00718.81
8.1.250.0250.00718.82
8.1.240.0230.00618.77
8.1.230.0220.00718.77
8.1.220.0220.00618.56
8.1.210.0210.00918.70
8.1.200.0220.00620.97
8.1.190.0210.00720.56
8.1.180.0200.00720.43
8.1.170.0190.00620.39
8.1.160.0190.00620.38
8.1.150.0190.00620.45
8.1.140.0190.00520.26
8.1.130.0180.00619.92
8.1.120.0170.00619.76
8.1.110.0180.00519.70
8.1.100.0180.00519.64
8.1.90.0180.00519.67
8.1.80.0160.00619.39
8.1.70.0170.00619.44
8.1.60.0180.00619.50
8.1.50.0170.00619.46
8.1.40.0160.00719.37
8.1.30.0180.00619.48
8.1.20.0170.00619.42
8.1.10.0160.00619.27
8.1.00.0160.00619.23
8.0.300.0230.00717.98
8.0.290.0240.00620.52
8.0.280.0200.00619.84
8.0.270.0190.00619.81
8.0.260.0190.00519.53
8.0.250.0170.00519.34
8.0.240.0170.00519.18
8.0.230.0180.00519.24
8.0.220.0170.00519.18
8.0.210.0150.00618.93
8.0.200.0160.00518.97
8.0.190.0150.00618.96
8.0.180.0160.00518.95
8.0.170.0160.00618.92
8.0.160.0160.00418.85
8.0.150.0160.00618.76
8.0.140.0160.00518.73
8.0.130.0170.00518.76
8.0.120.0150.00618.74
8.0.110.0150.00518.70
8.0.100.0150.00618.61
8.0.90.0170.00518.70
8.0.80.0160.00518.68
8.0.70.0160.00618.62
8.0.60.0150.00618.65
8.0.50.0150.00518.64
8.0.30.0140.00718.34
8.0.20.0130.00718.34
8.0.10.0140.00618.37
8.0.00.0130.00618.51
7.4.330.0160.00518.98
7.4.320.0180.00618.97
7.4.300.0160.00618.76
7.4.290.0160.00518.77
7.4.280.0170.00518.64
7.4.270.0160.00518.57
7.4.260.0160.00518.58
7.4.250.0150.00618.57
7.4.240.0150.00518.52
7.4.230.0150.00518.48
7.4.220.0140.00518.52
7.4.210.0140.00518.42
7.4.200.0150.00518.47
7.4.190.0150.00518.42
7.4.180.0140.00618.46
7.4.160.0130.00718.14
7.4.150.0140.00618.00
7.4.140.0130.00617.93
7.4.130.0130.00617.89
7.4.120.0130.00617.83
7.4.110.0150.00617.76
7.4.100.0130.00717.75
7.4.90.0140.00617.67
7.4.80.0140.00617.68
7.4.70.0130.00717.67
7.4.60.0140.00717.67
7.4.50.0130.00717.55
7.4.40.0130.00617.49
7.4.30.0130.00717.49
7.4.20.0120.00717.44
7.4.10.0130.00717.39
7.4.00.0110.00817.34
7.3.330.0160.00518.38
7.3.320.0160.00518.36
7.3.310.0160.00518.31
7.3.300.0160.00518.31
7.3.290.0160.00418.26
7.3.280.0150.00518.17
7.3.270.0150.00517.80
7.3.260.0140.00617.78
7.3.250.0130.00617.76
7.3.240.0140.00617.66
7.3.230.0140.00617.61
7.3.220.0150.00617.53
7.3.210.0150.00617.49
7.3.200.0140.00617.53
7.3.190.0130.00717.51
7.3.180.0140.00717.50
7.3.170.0150.00617.41
7.3.160.0130.00817.36
7.3.150.0130.00817.31
7.3.140.0130.00717.29
7.3.130.0130.00717.22
7.3.120.0130.00717.12
7.3.110.0130.00717.09
7.3.100.0130.00717.08
7.3.90.0130.00717.22
7.3.80.0130.00717.12
7.3.70.0130.00717.18
7.3.60.0120.00817.20
7.3.50.0130.00717.22
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.69
7.2.340.0160.00717.72
7.2.330.0160.00717.60
7.2.320.0160.00717.62
7.2.310.0150.00717.60
7.2.300.0150.00717.61
7.2.290.0140.00717.49
7.2.280.0150.00817.45
7.2.270.0150.00717.43
7.2.260.0150.00717.35
7.2.250.0140.00817.24
7.2.240.0140.00817.24
7.2.230.0150.00717.25
7.2.220.0140.00817.26
7.2.210.0130.00817.23
7.2.200.0150.00817.32
7.2.190.0150.00817.32
7.2.180.0150.00817.32
7.2.170.0140.00817.33
7.2.160.0140.00817.39
7.2.150.0160.00718.00
7.2.140.0150.00718.00
7.2.130.0170.00818.02
7.2.120.0160.00718.00
7.2.110.0160.00718.00
7.2.100.0170.00718.01
7.2.90.0180.00817.98
7.2.80.0150.00717.98
7.2.70.0170.00717.99
7.2.60.0150.00817.99
7.2.50.0160.00817.98
7.2.40.0150.00718.02
7.2.30.0150.00818.01
7.2.20.0160.00718.03
7.2.10.0160.00718.04
7.2.00.0150.00818.00

preferences:
83.59 ms | 1599 KiB | 5 Q