-
Notifications
You must be signed in to change notification settings - Fork 0
/
test4.php
64 lines (51 loc) · 2.16 KB
/
test4.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContext.php');
//require(__DIR__ . '/vendor/symfony/symfony/src/');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/RequestContextAwareInterface.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcher.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php');
require(__DIR__ . '/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php');
require('original.php');
use Symfony\Component\Routing\RequestContext;
$context = new RequestContext();
$matcher = new appDevUrlMatcher($context);
$withBlackfire = getopt('', ['with-blackfire']) ? true:false;
if ($withBlackfire) {
$blackfire = new \Blackfire\Client();
$probe = $blackfire->createProbe();
}
$max = 100000;
$start = microtime(true);
// Best case ==> first route
for ($i=0; $i < $max; $i++) {
$matcher->match('/dictionnaire/fr/');
}
echo 'Best case : ' . (microtime(true) - $start) . "\n";
// Middle case
$start = microtime(true);
for ($i=0; $i < $max; $i++) {
$matcher->match('/dictionnaire/fr/recherche-top/');
}
echo 'Middle case : ' . (microtime(true) - $start) . "\n";
// Worst case found
for ($i=0; $i < $max; $i++) {
$matcher->match('/dictionnaire/fr/definition/manger/');
}
echo 'Worst case : ' . (microtime(true) - $start) . "\n";
// Worst case not found
$start = microtime(true);
for ($i=0; $i < $max; $i++) {
try {
$matcher->match('/dictionnaire/fr/recherches');
} catch (\Exception $e) {
// I don't care, it's not the point here
}
}
echo 'Not found : ' . (microtime(true) - $start) . "\n";
if ($withBlackfire) {
$blackfire->endProbe($probe);
}