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.4.140.0370.01217.42
8.4.130.0410.01017.82
8.4.120.0360.01517.55
8.4.110.0410.01117.53
8.4.100.0400.01017.81
8.4.90.0420.00917.64
8.4.80.0400.01117.66
8.4.70.0350.00918.21
8.4.60.0370.00817.75
8.4.50.0400.01117.68
8.4.40.0390.00817.51
8.4.30.0390.01017.49
8.4.20.0330.00917.47
8.4.10.0340.01017.43
8.3.270.0360.00816.18
8.3.260.0420.00816.49
8.3.250.0390.01016.49
8.3.240.0320.01216.95
8.3.230.0330.00716.53
8.3.220.0400.00616.51
8.3.210.0340.00816.93
8.3.200.0350.00617.03
8.3.190.0310.00616.88
8.3.180.0270.00717.16
8.3.170.0330.00716.68
8.3.160.0320.00716.67
8.3.150.0290.00716.62
8.3.140.0330.00816.65
8.3.130.0310.00616.66
8.3.120.0260.00516.67
8.3.110.0280.00717.14
8.3.100.0320.00917.18
8.3.90.0350.00817.95
8.3.80.0330.00917.95
8.3.70.0340.00717.95
8.3.60.0320.00817.96
8.3.50.0320.00717.93
8.3.40.0310.00818.62
8.3.30.0250.00718.60
8.3.20.0240.00819.12
8.3.10.0260.00919.23
8.3.00.0190.00719.32
8.2.290.0340.00616.56
8.2.280.0280.00716.75
8.2.270.0310.00816.61
8.2.260.0270.01016.56
8.2.250.0260.00816.73
8.2.240.0260.00916.64
8.2.230.0280.00717.07
8.2.220.0260.00717.11
8.2.210.0260.00617.90
8.2.200.0280.00817.88
8.2.190.0320.00617.93
8.2.180.0270.01017.93
8.2.170.0320.00818.81
8.2.160.0290.00618.74
8.2.150.0310.00719.23
8.2.140.0290.00819.21
8.2.130.0320.00719.26
8.2.120.0320.00819.19
8.2.110.0280.00619.60
8.2.100.0270.00819.37
8.2.90.0280.00718.91
8.2.80.0250.00918.83
8.2.70.0270.00721.62
8.2.60.0260.00621.07
8.2.50.0230.00821.13
8.2.40.0220.00620.90
8.2.30.0200.00720.80
8.2.20.0190.00620.77
8.2.10.0220.00520.78
8.2.00.0210.00520.69
8.1.330.0320.00915.89
8.1.320.0310.00716.57
8.1.310.0290.00716.34
8.1.300.0310.00716.24
8.1.290.0300.00817.69
8.1.280.0280.00617.66
8.1.270.0260.00719.08
8.1.260.0260.00719.10
8.1.250.0260.00619.09
8.1.240.0230.00619.00
8.1.230.0210.00818.99
8.1.220.0210.00618.70
8.1.210.0210.00918.89
8.1.200.0220.00621.45
8.1.190.0210.00720.94
8.1.180.0200.00720.80
8.1.170.0190.00620.72
8.1.160.0190.00620.67
8.1.150.0180.00620.76
8.1.140.0190.00520.54
8.1.130.0180.00620.14
8.1.120.0170.00619.94
8.1.110.0180.00519.87
8.1.100.0170.00519.79
8.1.90.0180.00519.84
8.1.80.0160.00619.51
8.1.70.0160.00619.57
8.1.60.0180.00519.62
8.1.50.0170.00619.59
8.1.40.0160.00719.48
8.1.30.0180.00619.59
8.1.20.0170.00619.53
8.1.10.0160.00619.38
8.1.00.0160.00619.34
8.0.300.0230.00718.17
8.0.290.0240.00621.03
8.0.280.0190.00620.17
8.0.270.0190.00620.12
8.0.260.0180.00519.78
8.0.250.0160.00519.54
8.0.240.0160.00519.36
8.0.230.0180.00519.42
8.0.220.0170.00519.36
8.0.210.0150.00619.07
8.0.200.0160.00519.10
8.0.190.0150.00619.10
8.0.180.0160.00419.09
8.0.170.0160.00519.05
8.0.160.0160.00418.97
8.0.150.0150.00618.89
8.0.140.0160.00518.84
8.0.130.0170.00518.87
8.0.120.0150.00618.86
8.0.110.0150.00518.82
8.0.100.0150.00618.72
8.0.90.0160.00518.82
8.0.80.0160.00518.80
8.0.70.0150.00618.72
8.0.60.0150.00618.76
8.0.50.0150.00518.75
8.0.30.0130.00718.41
8.0.20.0130.00718.40
8.0.10.0140.00618.43
8.0.00.0130.00618.57
7.4.330.0160.00519.17
7.4.320.0170.00619.16
7.4.300.0160.00618.91
7.4.290.0160.00518.92
7.4.280.0160.00518.78
7.4.270.0150.00518.69
7.4.260.0150.00518.71
7.4.250.0150.00618.70
7.4.240.0150.00518.64
7.4.230.0150.00518.60
7.4.220.0140.00518.64
7.4.210.0140.00518.54
7.4.200.0140.00518.58
7.4.190.0150.00518.53
7.4.180.0140.00618.57
7.4.160.0120.00718.22
7.4.150.0130.00618.07
7.4.140.0120.00617.99
7.4.130.0120.00617.96
7.4.120.0130.00617.89
7.4.110.0140.00617.82
7.4.100.0120.00717.80
7.4.90.0140.00617.71
7.4.80.0140.00617.72
7.4.70.0130.00717.71
7.4.60.0130.00717.72
7.4.50.0120.00717.59
7.4.40.0130.00617.52
7.4.30.0130.00717.53
7.4.20.0120.00717.47
7.4.10.0120.00717.41
7.4.00.0110.00817.36
7.3.330.0150.00518.51
7.3.320.0160.00518.48
7.3.310.0160.00518.43
7.3.300.0150.00518.43
7.3.290.0160.00418.37
7.3.280.0150.00518.27
7.3.270.0150.00517.87
7.3.260.0140.00617.85
7.3.250.0130.00617.82
7.3.240.0140.00617.71
7.3.230.0140.00617.66
7.3.220.0150.00617.58
7.3.210.0150.00617.53
7.3.200.0140.00617.58
7.3.190.0130.00717.56
7.3.180.0140.00717.54
7.3.170.0140.00617.45
7.3.160.0130.00817.39
7.3.150.0130.00817.35
7.3.140.0130.00817.33
7.3.130.0130.00717.25
7.3.120.0120.00717.14
7.3.110.0130.00717.11
7.3.100.0130.00717.10
7.3.90.0130.00717.23
7.3.80.0130.00717.14
7.3.70.0130.00717.21
7.3.60.0120.00817.22
7.3.50.0130.00717.24
7.3.40.0130.00717.20
7.3.30.0130.00717.23
7.3.20.0140.00717.73
7.3.10.0130.00717.70
7.3.00.0150.00717.69
7.2.340.0150.00717.77
7.2.330.0160.00717.64
7.2.320.0160.00717.66
7.2.310.0150.00717.65
7.2.300.0150.00717.66
7.2.290.0140.00717.52
7.2.280.0140.00817.49
7.2.270.0150.00717.46
7.2.260.0150.00717.38
7.2.250.0140.00817.27
7.2.240.0140.00817.26
7.2.230.0150.00717.28
7.2.220.0140.00817.28
7.2.210.0130.00817.26
7.2.200.0140.00817.34
7.2.190.0150.00817.34
7.2.180.0140.00817.34
7.2.170.0140.00817.35
7.2.160.0140.00817.41
7.2.150.0160.00818.01
7.2.140.0150.00718.01
7.2.130.0160.00818.02
7.2.120.0160.00718.00
7.2.110.0160.00818.01
7.2.100.0170.00718.02
7.2.90.0180.00817.98
7.2.80.0150.00717.98
7.2.70.0170.00718.00
7.2.60.0150.00817.99
7.2.50.0150.00817.98
7.2.40.0150.00718.03
7.2.30.0140.00818.02
7.2.20.0160.00718.03
7.2.10.0160.00718.05
7.2.00.0150.00818.00

preferences:
32.23 ms | 403 KiB | 5 Q