1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Performance\Query; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
use Doctrine\DBAL\Types\DateTimeType; |
9
|
|
|
use Doctrine\ORM\Query; |
10
|
|
|
use Doctrine\Performance\EntityManagerFactory; |
11
|
|
|
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods; |
|
|
|
|
12
|
|
|
use function range; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @BeforeMethods({"init"}) |
16
|
|
|
*/ |
17
|
|
|
final class QueryBoundParameterProcessingBench |
18
|
|
|
{ |
19
|
|
|
/** @var Query */ |
20
|
|
|
private $parsedQueryWithInferredParameterType; |
21
|
|
|
|
22
|
|
|
/** @var Query */ |
23
|
|
|
private $parsedQueryWithDeclaredParameterType; |
24
|
|
|
|
25
|
|
|
public function init() : void |
26
|
|
|
{ |
27
|
|
|
$entityManager = EntityManagerFactory::makeEntityManagerWithNoResultsConnection(); |
28
|
|
|
|
29
|
|
|
// Note: binding a lot of parameters because DQL operations are noisy due to hydrators and other components |
30
|
|
|
// kicking in, so we make the parameter operations more noticeable. |
31
|
|
|
$dql = <<<'DQL' |
32
|
|
|
SELECT e |
33
|
|
|
FROM Doctrine\Tests\Models\Generic\DateTimeModel e |
34
|
|
|
WHERE |
35
|
|
|
e.datetime = :parameter1 |
36
|
|
|
OR |
37
|
|
|
e.datetime = :parameter2 |
38
|
|
|
OR |
39
|
|
|
e.datetime = :parameter3 |
40
|
|
|
OR |
41
|
|
|
e.datetime = :parameter4 |
42
|
|
|
OR |
43
|
|
|
e.datetime = :parameter5 |
44
|
|
|
OR |
45
|
|
|
e.datetime = :parameter6 |
46
|
|
|
OR |
47
|
|
|
e.datetime = :parameter7 |
48
|
|
|
OR |
49
|
|
|
e.datetime = :parameter8 |
50
|
|
|
OR |
51
|
|
|
e.datetime = :parameter9 |
52
|
|
|
OR |
53
|
|
|
e.datetime = :parameter10 |
54
|
|
|
DQL; |
55
|
|
|
|
56
|
|
|
$this->parsedQueryWithInferredParameterType = $entityManager->createQuery($dql); |
57
|
|
|
$this->parsedQueryWithDeclaredParameterType = $entityManager->createQuery($dql); |
58
|
|
|
|
59
|
|
|
foreach (range(1, 10) as $index) { |
60
|
|
|
$this->parsedQueryWithInferredParameterType->setParameter('parameter' . $index, new DateTime()); |
61
|
|
|
$this->parsedQueryWithDeclaredParameterType->setParameter('parameter' . $index, new DateTime(), DateTimeType::DATETIME); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
// Force parsing upfront - we don't benchmark that bit in this scenario |
65
|
|
|
$this->parsedQueryWithInferredParameterType->getSQL(); |
66
|
|
|
$this->parsedQueryWithDeclaredParameterType->getSQL(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function benchExecuteParsedQueryWithInferredParameterType() : void |
70
|
|
|
{ |
71
|
|
|
$this->parsedQueryWithInferredParameterType->execute(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function benchExecuteParsedQueryWithDeclaredParameterType() : void |
75
|
|
|
{ |
76
|
|
|
$this->parsedQueryWithDeclaredParameterType->execute(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths