3v4l.org

run code in 300+ 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.0290.00817.42
8.5.20.0370.00616.49
8.5.10.0350.00716.56
8.5.00.0420.00616.71
8.4.180.0130.01019.55
8.4.170.0330.00919.68
8.4.160.0330.01019.47
8.4.150.0340.00919.62
8.4.140.0350.01417.32
8.4.130.0410.00917.62
8.4.120.0350.01117.59
8.4.110.0330.00817.55
8.4.100.0370.01117.79
8.4.90.0420.00817.66
8.4.80.0380.01217.66
8.4.70.0360.00918.09
8.4.60.0370.00817.75
8.4.50.0400.01117.71
8.4.40.0390.00817.53
8.4.30.0390.01017.50
8.4.20.0340.00917.48
8.4.10.0350.01017.45
8.3.300.0380.01218.36
8.3.290.0350.00918.01
8.3.280.0310.01018.33
8.3.270.0410.00816.35
8.3.260.0390.01016.57
8.3.250.0390.00916.53
8.3.240.0320.01116.74
8.3.230.0330.00716.53
8.3.220.0380.00816.51
8.3.210.0340.00816.88
8.3.200.0350.00716.97
8.3.190.0310.00716.83
8.3.180.0290.00717.07
8.3.170.0340.00816.67
8.3.160.0330.00716.65
8.3.150.0300.00816.62
8.3.140.0330.00816.64
8.3.130.0310.00616.64
8.3.120.0270.00616.65
8.3.110.0290.00717.09
8.3.100.0330.00917.12
8.3.90.0350.00817.84
8.3.80.0330.00917.82
8.3.70.0340.00717.82
8.3.60.0330.00817.85
8.3.50.0330.00717.80
8.3.40.0310.00918.55
8.3.30.0260.00718.53
8.3.20.0240.00819.03
8.3.10.0270.00919.12
8.3.00.0200.00719.23
8.2.300.0450.01018.10
8.2.290.0340.00716.56
8.2.280.0280.00716.71
8.2.270.0310.00816.59
8.2.260.0270.01016.55
8.2.250.0270.00816.71
8.2.240.0260.00916.61
8.2.230.0280.00717.02
8.2.220.0270.00717.07
8.2.210.0270.00617.77
8.2.200.0280.00817.76
8.2.190.0320.00617.81
8.2.180.0270.01017.81
8.2.170.0320.00818.76
8.2.160.0300.00618.66
8.2.150.0310.00719.13
8.2.140.0290.00819.11
8.2.130.0320.00719.15
8.2.120.0310.00819.08
8.2.110.0280.00619.50
8.2.100.0280.00819.28
8.2.90.0280.00718.85
8.2.80.0260.00918.77
8.2.70.0270.00721.45
8.2.60.0260.00620.94
8.2.50.0230.00821.00
8.2.40.0220.00620.79
8.2.30.0210.00720.69
8.2.20.0200.00620.67
8.2.10.0220.00520.68
8.2.00.0210.00620.59
8.1.340.0410.00817.42
8.1.330.0320.00816.06
8.1.320.0310.00716.48
8.1.310.0290.00716.30
8.1.300.0310.00716.22
8.1.290.0300.00817.56
8.1.280.0280.00717.54
8.1.270.0260.00818.98
8.1.260.0260.00818.99
8.1.250.0260.00719.00
8.1.240.0240.00618.92
8.1.230.0220.00818.91
8.1.220.0220.00618.65
8.1.210.0210.00918.82
8.1.200.0230.00621.28
8.1.190.0210.00720.81
8.1.180.0200.00720.67
8.1.170.0190.00620.60
8.1.160.0190.00620.57
8.1.150.0190.00620.65
8.1.140.0190.00520.45
8.1.130.0180.00620.06
8.1.120.0170.00619.87
8.1.110.0180.00519.81
8.1.100.0170.00519.74
8.1.90.0180.00519.78
8.1.80.0160.00619.47
8.1.70.0160.00619.52
8.1.60.0180.00619.58
8.1.50.0170.00619.54
8.1.40.0160.00719.44
8.1.30.0180.00619.56
8.1.20.0170.00619.50
8.1.10.0160.00619.34
8.1.00.0160.00619.30
8.0.300.0230.00718.10
8.0.290.0250.00620.85
8.0.280.0200.00620.06
8.0.270.0190.00620.00
8.0.260.0190.00619.69
8.0.250.0170.00519.47
8.0.240.0160.00519.30
8.0.230.0180.00519.36
8.0.220.0170.00519.30
8.0.210.0150.00619.02
8.0.200.0160.00519.06
8.0.190.0150.00619.05
8.0.180.0170.00519.04
8.0.170.0160.00619.01
8.0.160.0160.00418.93
8.0.150.0160.00618.84
8.0.140.0160.00518.80
8.0.130.0170.00518.84
8.0.120.0150.00618.82
8.0.110.0150.00518.78
8.0.100.0150.00618.68
8.0.90.0170.00518.77
8.0.80.0160.00518.76
8.0.70.0160.00618.68
8.0.60.0150.00618.73
8.0.50.0150.00518.71
8.0.30.0140.00718.39
8.0.20.0130.00718.38
8.0.10.0140.00618.41
8.0.00.0130.00618.55
7.4.330.0160.00519.11
7.4.320.0180.00619.09
7.4.300.0160.00618.86
7.4.290.0160.00518.87
7.4.280.0160.00518.73
7.4.270.0150.00518.65
7.4.260.0150.00518.67
7.4.250.0150.00618.66
7.4.240.0150.00518.60
7.4.230.0150.00518.56
7.4.220.0140.00518.60
7.4.210.0140.00518.50
7.4.200.0140.00518.54
7.4.190.0150.00518.50
7.4.180.0140.00618.53
7.4.160.0120.00718.19
7.4.150.0140.00618.05
7.4.140.0130.00617.97
7.4.130.0130.00617.94
7.4.120.0130.00617.87
7.4.110.0150.00617.80
7.4.100.0130.00717.78
7.4.90.0140.00617.70
7.4.80.0140.00617.71
7.4.70.0130.00717.70
7.4.60.0130.00717.70
7.4.50.0120.00717.58
7.4.40.0130.00717.51
7.4.30.0130.00717.52
7.4.20.0120.00717.46
7.4.10.0120.00717.40
7.4.00.0110.00817.36
7.3.330.0160.00518.47
7.3.320.0160.00518.44
7.3.310.0160.00518.39
7.3.300.0160.00518.39
7.3.290.0160.00418.34
7.3.280.0160.00518.24
7.3.270.0150.00517.84
7.3.260.0140.00617.83
7.3.250.0130.00617.80
7.3.240.0140.00617.69
7.3.230.0140.00617.64
7.3.220.0150.00617.57
7.3.210.0150.00617.52
7.3.200.0140.00717.56
7.3.190.0130.00717.54
7.3.180.0140.00717.53
7.3.170.0150.00617.44
7.3.160.0130.00817.38
7.3.150.0130.00817.33
7.3.140.0130.00817.32
7.3.130.0130.00717.24
7.3.120.0130.00717.13
7.3.110.0130.00717.11
7.3.100.0130.00717.09
7.3.90.0130.00717.23
7.3.80.0130.00717.14
7.3.70.0130.00717.20
7.3.60.0120.00817.21
7.3.50.0130.00717.23
7.3.40.0130.00717.19
7.3.30.0130.00717.23
7.3.20.0140.00717.72
7.3.10.0130.00717.69
7.3.00.0150.00717.68
7.2.340.0160.00717.76
7.2.330.0160.00717.63
7.2.320.0160.00717.65
7.2.310.0150.00717.63
7.2.300.0150.00717.64
7.2.290.0140.00717.51
7.2.280.0140.00817.48
7.2.270.0150.00717.45
7.2.260.0150.00717.37
7.2.250.0140.00817.26
7.2.240.0140.00817.25
7.2.230.0150.00717.27
7.2.220.0140.00817.27
7.2.210.0130.00817.25
7.2.200.0140.00817.33
7.2.190.0150.00817.33
7.2.180.0140.00817.33
7.2.170.0140.00817.34
7.2.160.0140.00817.40
7.2.150.0160.00717.99
7.2.140.0150.00717.99
7.2.130.0160.00818.01
7.2.120.0160.00717.99
7.2.110.0160.00818.00
7.2.100.0170.00718.00
7.2.90.0180.00817.97
7.2.80.0150.00717.97
7.2.70.0170.00717.98
7.2.60.0150.00817.98
7.2.50.0160.00817.97
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.00817.99

preferences:
31.64 ms | 475 KiB | 5 Q