fork download
  1. <?php
  2.  
  3. $tests = 1000000;
  4.  
  5. $start = microtime( TRUE );
  6. for( $i = 1; $i <= $tests; $i += 1 ) {
  7. preg_match('/a*b/','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac');
  8. }
  9. $stop = microtime( TRUE );
  10.  
  11. printf( "For /a*b/ : %1.15f per iteration for %s iterations\n", ($stop - $start)/$tests, $tests );
  12. unset( $stop, $start );
  13.  
  14. $start = microtime( TRUE );
  15. for( $i = 1; $i <= $tests; $i += 1 ) {
  16. preg_match('/(?>a*)b/','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac');
  17. }
  18. $stop = microtime( TRUE );
  19.  
  20. printf( "For /(?>a*)b/: %1.15f per iteration for %s iterations\n", ($stop - $start)/$tests, $tests );
  21. unset( $stop, $start );
  22.  
  23. $start = microtime( TRUE );
  24. for( $i = 1; $i <= $tests; $i += 1 ) {
  25. preg_match('/a*+b/','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac');
  26. }
  27. $stop = microtime( TRUE );
  28.  
  29. printf( "For /a*+b/ : %1.15f per iteration for %s iterations\n", ($stop - $start)/$tests, $tests );
  30. unset( $stop, $start );
  31.  
  32. $start = microtime( TRUE );
  33. for( $i = 1; $i <= $tests; $i += 1 ) {
  34. preg_match('/(?>a)*b/','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac');
  35. }
  36. $stop = microtime( TRUE );
  37.  
  38. printf( "For /(?>a)*b/: %1.15f per iteration for %s iterations\n", ($stop - $start)/$tests, $tests );
  39. unset( $stop, $start );
Success #stdin #stdout 3.58s 20568KB
stdin
Standard input is empty
stdout
For /a*b/    : 0.000000886368990 per iteration for 1000000 iterations
For /(?>a*)b/: 0.000000898101091 per iteration for 1000000 iterations
For /a*+b/   : 0.000000886687040 per iteration for 1000000 iterations
For /(?>a)*b/: 0.000000896517038 per iteration for 1000000 iterations