Guest User

Untitled

a guest
Jul 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. <?php
  2.  
  3. $original = 'prepend/youtube#video/postpend';
  4. $counter = 1000;
  5.  
  6. $start = microtime(true);
  7.  
  8. for ($walk = 0; $walk < $counter; $walk++) {
  9. $computed = preg_replace('/youtube#video/', '', $original);
  10. }
  11.  
  12. $end = microtime(true);
  13.  
  14. echo sprintf('preg_replace took %f', $end - $start) . PHP_EOL;
  15.  
  16. $start = microtime(true);
  17.  
  18. for ($walk = 0; $walk < $counter; $walk++) {
  19. $computed = str_replace('/youtube#video/', '', $original);
  20. }
  21.  
  22. $end = microtime(true);
  23.  
  24. echo sprintf('str_replace took %f', $end - $start) . PHP_EOL;
Add Comment
Please, Sign In to add comment