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.110.0380.01017.80
8.4.100.0370.01018.01
8.4.90.0430.01017.68
8.4.80.0400.01217.79
8.4.70.0330.00718.48
8.4.60.0370.00617.80
8.4.50.0390.01117.70
8.4.40.0380.00717.51
8.4.30.0380.01017.47
8.4.20.0340.00917.48
8.4.10.0340.00917.44
8.3.240.0270.01217.12
8.3.230.0270.00516.50
8.3.220.0410.00616.59
8.3.210.0320.00717.16
8.3.200.0340.00417.15
8.3.190.0290.00617.00
8.3.180.0260.00517.29
8.3.170.0330.00716.71
8.3.160.0310.00716.74
8.3.150.0280.00716.67
8.3.140.0310.00816.69
8.3.130.0310.00516.69
8.3.120.0250.00516.68
8.3.110.0280.00617.24
8.3.100.0310.00917.27
8.3.90.0340.00818.09
8.3.80.0320.00918.09
8.3.70.0330.00718.08
8.3.60.0310.00818.09
8.3.50.0320.00718.06
8.3.40.0310.00818.75
8.3.30.0240.00718.73
8.3.20.0240.00819.29
8.3.10.0260.00919.41
8.3.00.0190.00719.50
8.2.290.0280.00816.43
8.2.280.0280.00716.81
8.2.270.0310.00716.65
8.2.260.0260.01016.57
8.2.250.0260.00816.77
8.2.240.0250.00916.68
8.2.230.0270.00717.15
8.2.220.0260.00717.21
8.2.210.0260.00618.04
8.2.200.0280.00818.04
8.2.190.0320.00618.04
8.2.180.0260.01018.07
8.2.170.0320.00718.94
8.2.160.0290.00618.87
8.2.150.0310.00719.40
8.2.140.0280.00719.38
8.2.130.0310.00719.41
8.2.120.0310.00819.36
8.2.110.0270.00619.75
8.2.100.0270.00819.51
8.2.90.0280.00718.99
8.2.80.0250.00918.92
8.2.70.0270.00721.84
8.2.60.0260.00621.23
8.2.50.0220.00821.30
8.2.40.0210.00621.06
8.2.30.0200.00620.94
8.2.20.0180.00620.91
8.2.10.0210.00520.91
8.2.00.0210.00520.82
8.1.330.0290.01016.05
8.1.320.0310.00716.63
8.1.310.0290.00716.41
8.1.300.0310.00716.26
8.1.290.0300.00817.83
8.1.280.0270.00717.84
8.1.270.0250.00719.27
8.1.260.0250.00719.28
8.1.250.0250.00619.25
8.1.240.0230.00619.15
8.1.230.0200.00819.13
8.1.220.0210.00518.80
8.1.210.0200.00918.99
8.1.200.0220.00621.67
8.1.190.0200.00621.13
8.1.180.0190.00720.96
8.1.170.0190.00520.87
8.1.160.0180.00620.81
8.1.150.0180.00620.89
8.1.140.0180.00420.67
8.1.130.0180.00620.24
8.1.120.0160.00620.01
8.1.110.0170.00519.94
8.1.100.0170.00519.86
8.1.90.0170.00419.92
8.1.80.0150.00619.57
8.1.70.0160.00619.63
8.1.60.0180.00519.68
8.1.50.0160.00619.64
8.1.40.0150.00719.54
8.1.30.0170.00619.65
8.1.20.0160.00619.58
8.1.10.0150.00619.43
8.1.00.0150.00619.39
8.0.300.0230.00618.27
8.0.290.0240.00621.26
8.0.280.0190.00620.32
8.0.270.0190.00520.25
8.0.260.0180.00519.89
8.0.250.0160.00519.63
8.0.240.0160.00519.45
8.0.230.0170.00519.50
8.0.220.0170.00419.44
8.0.210.0140.00619.14
8.0.200.0150.00519.16
8.0.190.0150.00619.17
8.0.180.0160.00419.16
8.0.170.0160.00519.11
8.0.160.0160.00419.02
8.0.150.0150.00518.95
8.0.140.0150.00518.90
8.0.130.0160.00518.93
8.0.120.0150.00618.91
8.0.110.0140.00518.88
8.0.100.0150.00618.77
8.0.90.0160.00518.87
8.0.80.0150.00518.84
8.0.70.0150.00618.76
8.0.60.0140.00618.82
8.0.50.0140.00518.80
8.0.30.0130.00718.45
8.0.20.0120.00718.43
8.0.10.0140.00618.46
8.0.00.0130.00618.60
7.4.330.0150.00519.26
7.4.320.0170.00619.25
7.4.300.0150.00618.98
7.4.290.0160.00518.99
7.4.280.0160.00518.84
7.4.270.0150.00518.75
7.4.260.0150.00418.76
7.4.250.0140.00618.76
7.4.240.0150.00418.69
7.4.230.0140.00518.65
7.4.220.0140.00518.69
7.4.210.0130.00518.59
7.4.200.0140.00518.64
7.4.190.0140.00418.59
7.4.180.0130.00618.63
7.4.160.0120.00718.26
7.4.150.0130.00618.11
7.4.140.0120.00618.03
7.4.130.0120.00617.98
7.4.120.0130.00617.91
7.4.110.0140.00617.84
7.4.100.0120.00717.82
7.4.90.0140.00617.74
7.4.80.0130.00617.75
7.4.70.0120.00717.73
7.4.60.0130.00717.74
7.4.50.0120.00717.61
7.4.40.0130.00717.54
7.4.30.0120.00717.54
7.4.20.0120.00717.48
7.4.10.0120.00717.43
7.4.00.0100.00817.38
7.3.330.0150.00518.57
7.3.320.0150.00518.54
7.3.310.0150.00518.49
7.3.300.0150.00518.48
7.3.290.0160.00418.42
7.3.280.0150.00518.32
7.3.270.0150.00517.89
7.3.260.0130.00517.88
7.3.250.0130.00617.85
7.3.240.0130.00617.74
7.3.230.0140.00617.69
7.3.220.0140.00617.61
7.3.210.0150.00617.55
7.3.200.0140.00617.60
7.3.190.0130.00717.58
7.3.180.0140.00717.57
7.3.170.0140.00617.47
7.3.160.0120.00817.41
7.3.150.0130.00817.36
7.3.140.0130.00817.34
7.3.130.0130.00717.27
7.3.120.0120.00717.15
7.3.110.0120.00717.13
7.3.100.0120.00717.11
7.3.90.0130.00717.25
7.3.80.0120.00717.16
7.3.70.0120.00717.22
7.3.60.0120.00817.23
7.3.50.0130.00717.25
7.3.40.0130.00717.21
7.3.30.0130.00717.24
7.3.20.0140.00717.75
7.3.10.0130.00717.72
7.3.00.0150.00717.71
7.2.340.0150.00717.80
7.2.330.0160.00717.67
7.2.320.0160.00717.68
7.2.310.0140.00717.67
7.2.300.0150.00717.68
7.2.290.0140.00717.54
7.2.280.0140.00817.50
7.2.270.0150.00717.48
7.2.260.0150.00717.39
7.2.250.0140.00817.28
7.2.240.0140.00817.27
7.2.230.0150.00717.29
7.2.220.0140.00817.29
7.2.210.0130.00817.27
7.2.200.0140.00817.35
7.2.190.0140.00817.35
7.2.180.0140.00817.36
7.2.170.0140.00817.36
7.2.160.0140.00817.42
7.2.150.0150.00818.03
7.2.140.0150.00718.02
7.2.130.0160.00818.04
7.2.120.0160.00718.02
7.2.110.0160.00818.03
7.2.100.0160.00718.04
7.2.90.0180.00818.00
7.2.80.0150.00718.00
7.2.70.0170.00718.01
7.2.60.0150.00818.01
7.2.50.0150.00818.00
7.2.40.0150.00718.05
7.2.30.0140.00818.04
7.2.20.0150.00718.04
7.2.10.0160.00718.07
7.2.00.0150.00818.02

preferences:
31.05 ms | 403 KiB | 5 Q