ExplodeLimit.php 867 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @package koseven/Codebench
  4. * @category Tests
  5. * @author Geert De Deckere <geert@idoe.be>
  6. */
  7. class Bench_ExplodeLimit extends Codebench {
  8. public $description =
  9. 'Having a look at the effect of adding a limit to the <a href="http://php.net/explode">explode</a> function.<br />
  10. http://stackoverflow.com/questions/1308149/how-to-get-a-part-of-url-between-4th-and-5th-slashes';
  11. public $loops = 10000;
  12. public $subjects = [
  13. 'http://example.com/articles/123a/view',
  14. 'http://example.com/articles/123a/view/x/x/x/x/x',
  15. 'http://example.com/articles/123a/view/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x',
  16. ];
  17. public function bench_explode_without_limit($subject)
  18. {
  19. $parts = explode('/', $subject);
  20. return $parts[4];
  21. }
  22. public function bench_explode_with_limit($subject)
  23. {
  24. $parts = explode('/', $subject, 6);
  25. return $parts[4];
  26. }
  27. }