-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMDDoIncludeViews.php
More file actions
executable file
·50 lines (42 loc) · 1.25 KB
/
MDDoIncludeViews.php
File metadata and controls
executable file
·50 lines (42 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php defined('SYSPATH') or die('No direct script access.');
/**
* @package Kohana/Codebench
* @category Tests
* @author Geert De Deckere <geert@idoe.be>
*/
class Bench_MDDoIncludeViews extends Codebench {
public $description =
'Optimization for the <code>doIncludeViews()</code> method of <code>Kohana_Kodoc_Markdown</code>
for the Kohana Userguide.';
public $loops = 10000;
public $subjects = array
(
// Valid matches
'{{one}} two {{three}}',
'{{userguide/examples/hello_world_error}}',
// Invalid matches
'{}',
'{{}}',
'{{userguide/examples/hello_world_error}',
'{{userguide/examples/hello_world_error }}',
'{{userguide/examples/{{hello_world_error }}',
);
public function bench_original($subject)
{
preg_match_all('/{{(\S+?)}}/app', $subject, $matches, PREG_SET_ORDER);
return $matches;
}
public function bench_possessive($subject)
{
// Using a possessive character class
// Removed useless /app modifier
preg_match_all('/{{([^\s{}]++)}}/', $subject, $matches, PREG_SET_ORDER);
return $matches;
}
public function bench_lookaround($subject)
{
// Using lookaround to move $mathes[1] into $matches[0]
preg_match_all('/(?<={{)[^\s{}]++(?=}})/', $subject, $matches, PREG_SET_ORDER);
return $matches;
}
}