3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "23456789ABCDEGHJKMNPQRSTUVXYZabcdeghjkmnpqrstuvxyz"; $excludes = ['cp','cb','ck','c6','c9','rn','rm','mm','co','do','cl','db','qp','qb','dp','ww']; $length = 5; $indexedExcludes = array_combine($excludes, $excludes); $dictionaryArray = str_split($str); function fastCaptcha(array $dictionary, array $excludedSyllables, int $length): string { $captcha = ''; $previousCharacter = ''; $generatedLength = 0; while ($generatedLength < $length) { $randomCharacter = $dictionary[array_rand($dictionary)]; if(array_key_exists($previousCharacter . $randomCharacter, $excludedSyllables)) { continue; } $captcha .= $randomCharacter; $previousCharacter = $randomCharacter; $generatedLength++; } return $captcha; } $excludesRegex = '/' . implode('|', $excludes) . '/'; function fuckedCaptcha(string $dictionary, string $excludedSyllables, int $length): string { do { $code = substr(str_shuffle(str_repeat($dictionary, 3)), 0, $length); } while (preg_match($excludedSyllables, $code)); return $code; } $t0 = microtime(true); for ($i = 0; $i < 100000; $i++) fuckedCaptcha($str, $excludesRegex, $length); $t1 = microtime(true); for ($i = 0; $i < 100000; $i++) fastCaptcha($dictionaryArray, $indexedExcludes, $length); $t2 = microtime(true); echo "regexp : " . ($t1 - $t0) . "\n"; echo "array index: " . ($t2 - $t1) . "\n";

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.3.20.0130.31625.66
8.3.10.0070.34425.66
8.3.00.0080.31925.66
8.2.150.0080.32325.66
8.2.140.0120.31225.66
8.2.130.0150.31425.66
8.2.120.0070.35025.66
8.2.110.0150.31525.66
8.2.100.0070.34325.66
8.2.90.0120.29925.66
8.2.80.0070.30525.66
8.2.70.0120.32225.66
8.2.60.0150.33125.66
8.2.50.0120.31925.66
8.2.40.0070.34525.66
8.2.30.0120.32725.66
8.2.20.0080.32225.66
8.2.10.0070.31125.66
8.2.00.0120.31725.66
8.1.270.0130.25925.66
8.1.260.0120.25825.66
8.1.250.0130.25225.66
8.1.240.0070.27025.66
8.1.230.0120.26725.66
8.1.220.0130.32925.66
8.1.210.0130.25725.66
8.1.200.0120.27325.66
8.1.190.0150.26625.66
8.1.180.0120.26425.66
8.1.170.0130.27125.66
8.1.160.0080.26625.66
8.1.150.0030.26225.66
8.1.140.0130.26425.66
8.1.130.0120.26925.66
8.1.120.0170.25425.66
8.1.110.0120.26225.66
8.1.100.0070.25725.66
8.1.90.0080.26925.66
8.1.80.0130.26425.66
8.1.70.0120.27325.66
8.1.60.0130.26825.66
8.1.50.0080.27825.66
8.1.40.0120.26925.66
8.1.30.0120.28725.66
8.1.20.0130.26725.66
8.1.10.0130.28325.66
8.1.00.0120.28925.66
8.0.300.0100.29925.66
8.0.290.0230.27825.66
8.0.280.0200.27425.66
8.0.270.0100.26925.66
8.0.260.0200.27225.66
8.0.250.0100.25525.66
8.0.240.0140.26325.66
8.0.230.0300.26925.66
8.0.220.0170.25325.66
8.0.210.0230.26225.66
8.0.200.0130.27225.66
8.0.190.0230.25325.66
8.0.180.0070.27425.66
8.0.170.0170.26025.66
8.0.160.0100.28725.66
8.0.150.0230.29025.66
8.0.140.0330.26325.66
8.0.130.0200.29525.66
8.0.120.0170.26425.66
8.0.110.0100.25625.66
8.0.100.0300.26025.66
8.0.90.0230.26825.66
8.0.80.0130.26925.66
8.0.70.0070.25825.66
8.0.60.0230.26825.66
8.0.50.0200.26325.66
8.0.30.0100.28125.66
8.0.20.0130.29325.66
8.0.10.0170.25825.66
8.0.00.0160.26725.66
7.4.330.0200.25225.66
7.4.320.0270.27025.66
7.4.300.0170.27425.66
7.4.290.0360.25325.66
7.4.280.0300.25525.66
7.4.270.0200.26225.66
7.4.260.0230.26525.66
7.4.250.0260.25325.66
7.4.240.0300.25625.66
7.4.230.0430.27925.66
7.4.220.0170.26125.66
7.4.210.0270.28725.66
7.4.200.0240.26625.66
7.4.190.0370.33225.66
7.4.180.0140.27125.66
7.4.160.0300.26625.66
7.4.150.0330.27425.66
7.4.140.0360.25725.66
7.4.130.0300.37725.66
7.4.120.0230.25225.66
7.4.110.0230.28925.66
7.4.100.0200.26825.66
7.4.90.0270.31625.66
7.4.80.0420.24025.66
7.4.70.0260.26325.66
7.4.60.0230.27525.66
7.4.50.0350.26725.66
7.4.40.0230.28925.66
7.4.30.0140.27625.66
7.4.20.0170.27525.66
7.4.10.0270.26525.66
7.4.00.0240.26025.66
7.3.330.0270.28125.66
7.3.320.0300.27525.66
7.3.310.0230.28125.66
7.3.300.0330.29925.66
7.3.290.0200.28625.66
7.3.280.0140.27425.66
7.3.270.0200.26925.66
7.3.260.0230.26925.66
7.3.250.0330.27725.66
7.3.240.0200.29425.66
7.3.230.0270.26925.66
7.3.220.0210.27025.66
7.3.210.0300.25825.66
7.3.200.0210.29825.66
7.3.190.0300.29925.66
7.3.180.0170.28025.66
7.3.170.0230.30925.66
7.3.160.0230.28125.66
7.3.150.0270.28425.66
7.3.140.0210.31025.66
7.3.130.0230.26525.66
7.3.120.0200.30825.66
7.3.110.0270.29525.66
7.3.100.0300.25925.66
7.3.90.0200.28625.66
7.3.80.0260.28425.66
7.3.70.0170.28925.66
7.3.60.0170.27225.66
7.3.50.0200.29425.66
7.3.40.0170.27125.66
7.3.30.0300.27325.66
7.3.20.0300.38725.66
7.3.10.0270.27225.66
7.3.00.0400.28525.66
7.2.340.0240.39025.66
7.2.330.0200.36625.66
7.2.320.0200.37125.66
7.2.310.0300.36125.66
7.2.300.0270.37925.66
7.2.290.0370.39125.66
7.2.280.0200.36025.66
7.2.270.0140.39225.66
7.2.260.0300.37325.66
7.2.250.0200.36225.66
7.2.240.0430.36525.66
7.2.230.0170.36225.66
7.2.220.0330.39125.66
7.2.210.0300.37725.66
7.2.200.0230.37325.66
7.2.190.0260.35925.66
7.2.180.0300.38325.66
7.2.170.0330.37925.66
7.2.160.0300.36325.66
7.2.150.0300.39325.66
7.2.140.0300.36925.66
7.2.130.0300.39825.66
7.2.120.0200.37025.66
7.2.110.0340.38425.66
7.2.100.0210.39425.66
7.2.90.0300.37125.66
7.2.80.0270.36125.66
7.2.70.0230.36325.66
7.2.60.0240.35725.66
7.2.50.0300.38925.66
7.2.40.0390.35725.66
7.2.30.0230.36325.66
7.2.20.0390.37325.66
7.2.10.0270.35625.66
7.2.00.0360.36125.66
7.1.330.0360.43825.66
7.1.320.0270.39025.66
7.1.310.0170.40525.66
7.1.300.0230.38025.66
7.1.290.0260.37325.66
7.1.280.0130.38625.66
7.1.270.0200.38225.66
7.1.260.0170.38025.66
7.1.250.0230.38525.66
7.1.240.0170.40525.66
7.1.230.0430.38225.66
7.1.220.0100.39425.66
7.1.210.0240.40725.66
7.1.200.0240.42025.66
7.1.190.0100.38725.66
7.1.180.0200.37925.66
7.1.170.0200.38025.66
7.1.160.0170.38225.66
7.1.150.0130.38325.66
7.1.140.0100.38825.66
7.1.130.0230.38625.66
7.1.120.0130.38525.66
7.1.110.0200.38125.66
7.1.100.0300.40125.66
7.1.90.0200.39925.66
7.1.80.0260.37625.66
7.1.70.0430.38325.66
7.1.60.0370.39425.66
7.1.50.0360.38925.66
7.1.40.0400.39825.66
7.1.30.0300.40725.66
7.1.20.0140.40425.66
7.1.10.0170.39625.66
7.1.00.0300.39325.66
7.0.330.0300.49325.66
7.0.320.0200.46825.66
7.0.310.0200.47425.66
7.0.300.0330.46925.66
7.0.290.0200.49925.66
7.0.280.0230.49425.66
7.0.270.0300.48725.66
7.0.260.0200.49325.66
7.0.250.0330.48425.66
7.0.240.0200.47425.66
7.0.230.0260.46925.66
7.0.220.0260.50725.66
7.0.210.0170.48525.66
7.0.200.0170.48625.66
7.0.190.0130.48425.66
7.0.180.0230.49325.66
7.0.170.0230.47525.66
7.0.160.0170.47825.66
7.0.150.0200.47725.66
7.0.140.0170.48225.66
7.0.130.0170.48525.66
7.0.120.0330.53225.66
7.0.110.0230.47125.66
7.0.100.0170.47625.66
7.0.90.0100.51025.66
7.0.80.0170.47625.66
7.0.70.0200.47225.66
7.0.60.0130.47025.66
7.0.50.0130.50525.66
7.0.40.0130.52225.66
7.0.30.0130.48725.66
7.0.20.0200.50125.66
7.0.10.0200.48225.66
7.0.00.0070.48525.66
5.6.400.0220.06325.66
5.6.390.0190.05125.66
5.6.380.0220.06125.66
5.6.370.0140.07625.66
5.6.360.0230.05725.66
5.6.350.0210.06725.66
5.6.340.0140.05525.66
5.6.330.0290.06425.66
5.6.320.0230.05025.66
5.6.310.0290.07225.66
5.6.300.0140.07625.66
5.6.290.0170.05725.66
5.6.280.0300.04625.66
5.6.270.0200.06725.66
5.6.260.0100.06425.66
5.6.250.0110.07825.66
5.6.240.0200.06525.66
5.6.230.0130.05625.66
5.6.220.0200.05725.66
5.6.210.0170.05825.66
5.6.200.0270.04725.66
5.6.190.0140.05925.66
5.6.180.0160.07725.66
5.6.170.0190.05525.66
5.6.160.0380.07425.66
5.6.150.0230.05325.66
5.6.140.0220.05425.66
5.6.130.0210.05325.66
5.6.120.0200.05625.66
5.6.110.0170.07825.66
5.6.100.0200.05625.66
5.6.90.0210.06025.66
5.6.80.0160.05325.66
5.6.70.0140.05925.66
5.6.60.0140.07125.66
5.6.50.0170.07325.66
5.6.40.0130.06925.66
5.6.30.0140.06125.66
5.6.20.0240.04525.66
5.6.10.0230.06625.66
5.6.00.0220.06725.66
5.5.380.0210.05525.66
5.5.370.0230.05625.66
5.5.360.0230.05325.66
5.5.350.0070.06925.66
5.5.340.0230.05225.66
5.5.330.0170.05925.66
5.5.320.0200.05425.66
5.5.310.0190.06825.66
5.5.300.0260.06925.66
5.5.290.0190.05525.66
5.5.280.0180.05725.66
5.5.270.0210.05825.66
5.5.260.0130.06025.66
5.5.250.0170.05725.66
5.5.240.0230.04925.66
5.5.230.0230.04925.66
5.5.220.0310.04125.66
5.5.210.0200.06025.66
5.5.200.0300.06625.66
5.5.190.0240.04725.66
5.5.180.0170.05825.66
5.5.170.0230.08225.66
5.5.160.0240.06225.66
5.5.150.0210.05025.66
5.5.140.0270.05125.66
5.5.130.0200.06725.66
5.5.120.0330.06525.66
5.5.110.0100.08025.66
5.5.100.0110.05325.66
5.5.90.0190.05325.66
5.5.80.0310.05925.66
5.5.70.0040.06825.66
5.5.60.0160.05425.66
5.5.50.0270.06425.66
5.5.40.0230.05225.66
5.5.30.0250.05725.66
5.5.20.0200.06825.66
5.5.10.0220.05025.66
5.5.00.0250.04625.66
5.4.450.0190.05125.66
5.4.440.0100.05925.66
5.4.430.0240.04425.66
5.4.420.0230.04525.66
5.4.410.0140.05425.66
5.4.400.0230.06625.66
5.4.390.0070.08425.66
5.4.380.0110.05525.66
5.4.370.0130.05325.66
5.4.360.0160.04825.66
5.4.350.0100.05325.66
5.4.340.0130.05325.66
5.4.330.0260.06225.66
5.4.320.0270.05025.66
5.4.310.0070.05725.66
5.4.300.0100.08125.66
5.4.290.0220.05125.66
5.4.280.0100.05425.66
5.4.270.0160.06525.66
5.4.260.0230.05625.66
5.4.250.0260.03925.66
5.4.240.0070.07025.66
5.4.230.0170.05825.66
5.4.220.0190.04525.66
5.4.210.0100.05025.66
5.4.200.0070.06825.66
5.4.190.0190.04725.66
5.4.180.0100.09025.66
5.4.170.0170.05925.66
5.4.160.0160.06725.66
5.4.150.0170.05625.66
5.4.140.0320.05025.66
5.4.130.0200.04625.66
5.4.120.0230.04325.66
5.4.110.0190.04825.66
5.4.100.0110.05325.66
5.4.90.0110.05325.66
5.4.80.0190.04525.66
5.4.70.0290.05225.66
5.4.60.0290.05825.66
5.4.50.0270.03725.66
5.4.40.0120.05525.66
5.4.30.0270.05425.66
5.4.20.0130.04825.66
5.4.10.0200.04125.66
5.4.00.0130.05025.66
5.3.290.0160.05325.66
5.3.280.0110.05325.66
5.3.270.0140.06825.66
5.3.260.0170.06725.66
5.3.250.0170.04425.66
5.3.240.0190.05025.66
5.3.230.0110.04925.66
5.3.220.0170.07325.66
5.3.210.0170.06225.66
5.3.200.0090.06925.66
5.3.190.0130.05125.66
5.3.180.0170.05025.66
5.3.170.0200.04625.66
5.3.160.0100.05525.66
5.3.150.0130.05225.66
5.3.140.0170.04825.66
5.3.130.0160.04925.66
5.3.120.0130.07525.66
5.3.110.0100.05025.66
5.3.100.0160.04725.66
5.3.90.0140.04725.66
5.3.80.0100.05425.66
5.3.70.0190.03825.66
5.3.60.0130.06525.66
5.3.50.0230.04025.66
5.3.40.0190.04525.66
5.3.30.0210.06625.66
5.3.20.0170.05025.66
5.3.10.0330.04325.66
5.3.00.0110.05025.66
5.2.170.0130.04025.66
5.2.160.0230.02925.66
5.2.150.0130.03925.66
5.2.140.0170.03425.66
5.2.130.0130.03925.66
5.2.120.0160.05125.66
5.2.110.0130.03825.66
5.2.100.0030.04725.66
5.2.90.0160.05025.66
5.2.80.0100.04025.66
5.2.70.0240.05125.66
5.2.60.0130.04425.66
5.2.50.0140.03825.66
5.2.40.0130.03525.66
5.2.30.0070.04025.66
5.2.20.0160.05525.66
5.2.10.0130.03925.66
5.2.00.0140.03525.66
5.1.60.0130.04225.66
5.1.50.0100.03225.66
5.1.40.0130.02925.66
5.1.30.0110.03625.66
5.1.20.0160.04725.66
5.1.10.0070.03925.66
5.1.00.0130.03525.66
5.0.50.0120.02325.66
5.0.40.0100.02725.66
5.0.30.0130.05025.66
5.0.20.0100.02425.66
5.0.10.0160.01925.66
5.0.00.0000.05025.66
4.4.90.0030.02125.66
4.4.80.0040.02025.66
4.4.70.0040.02225.66
4.4.60.0090.01525.66
4.4.50.0130.01325.66
4.4.40.0070.03125.66
4.4.30.0070.01725.66
4.4.20.0030.02025.66
4.4.10.0070.02025.66
4.4.00.0000.03925.66
4.3.110.0040.03325.66
4.3.100.0120.02125.66
4.3.90.0060.01625.66
4.3.80.0070.02725.66
4.3.70.0160.01625.66
4.3.60.0060.02325.66
4.3.50.0030.02725.66
4.3.40.0070.02925.66
4.3.30.0140.01825.66
4.3.20.0030.02725.66
4.3.10.0000.02725.66
4.3.00.0090.02725.66

preferences:
58.67 ms | 403 KiB | 5 Q