PageRenderTime 35ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/codebench/classes/bench/mddoincludeviews.php

https://bitbucket.org/seyar/parshin.local
PHP | 50 lines | 32 code | 8 blank | 10 comment | 0 complexity | 4fb78f2d44ec5eb013b0a3307fa927a6 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. /**
  3. * @package Kohana/Codebench
  4. * @category Tests
  5. * @author Geert De Deckere <geert@idoe.be>
  6. */
  7. class Bench_MDDoIncludeViews extends Codebench {
  8. public $description =
  9. 'Optimization for the <code>doIncludeViews()</code> method of <code>Kohana_Kodoc_Markdown</code>
  10. for the Kohana Userguide.';
  11. public $loops = 10000;
  12. public $subjects = array
  13. (
  14. // Valid matches
  15. '{{one}} two {{three}}',
  16. '{{userguide/examples/hello_world_error}}',
  17. // Invalid matches
  18. '{}',
  19. '{{}}',
  20. '{{userguide/examples/hello_world_error}',
  21. '{{userguide/examples/hello_world_error }}',
  22. '{{userguide/examples/{{hello_world_error }}',
  23. );
  24. public function bench_original($subject)
  25. {
  26. preg_match_all('/{{(\S+?)}}/m', $subject, $matches, PREG_SET_ORDER);
  27. return $matches;
  28. }
  29. public function bench_possessive($subject)
  30. {
  31. // Using a possessive character class
  32. // Removed useless /m modifier
  33. preg_match_all('/{{([^\s{}]++)}}/', $subject, $matches, PREG_SET_ORDER);
  34. return $matches;
  35. }
  36. public function bench_lookaround($subject)
  37. {
  38. // Using lookaround to move $mathes[1] into $matches[0]
  39. preg_match_all('/(?<={{)[^\s{}]++(?=}})/', $subject, $matches, PREG_SET_ORDER);
  40. return $matches;
  41. }
  42. }