fork download
  1. <?php
  2.  
  3. $t0 = microtime(true);
  4.  
  5. for ($i = 0; $i < 1000000; $i++) {
  6. $str = sprintf("23456789ABCDEGHJKMNPQRSTUVXYZabcdeghjkmnpqrstuvxyz%06d", 0);
  7. if (preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/', $str))
  8. break;
  9. }
  10.  
  11. $t1 = microtime(true);
  12.  
  13. for ($i = 0; $i < 1000000; $i++) {
  14. $str = sprintf("23456789ABCDEGHJKMNPQRSTUVXYZabcdeghjkmnpqrstuvxyz%06d", $i);
  15. if (preg_match('/cp|cb|ck|c6|c9|rn|rm|mm|co|do|cl|db|qp|qb|dp|ww/', $str))
  16. break;
  17. }
  18.  
  19. $t2 = microtime(true);
  20.  
  21. echo "const string: " . ($t1 - $t0) . " sec\n";
  22. echo "dynamic string: " . ($t2 - $t1) . " sec\n";
  23.  
Success #stdin #stdout 0.98s 26196KB
stdin
Standard input is empty
stdout
const string: 0.49209189414978 sec
dynamic string: 0.47230696678162 sec