1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bdf\Prime\Query; |
4
|
|
|
|
5
|
|
|
require_once __DIR__ . '/../_files/BenchData.php'; |
6
|
|
|
|
7
|
|
|
use Bdf\Prime\Bench\BenchData; |
8
|
|
|
use Bdf\Prime\Bench\User; |
9
|
|
|
use Bdf\Prime\Cache\ArrayCache; |
10
|
|
|
use Bdf\Prime\Connection\ConnectionConfig; |
|
|
|
|
11
|
|
|
use Bdf\Prime\ConnectionManager; |
12
|
|
|
use Bdf\Prime\Locatorizable; |
13
|
|
|
use Bdf\Prime\Query\Compiler\Preprocessor\OrmPreprocessor; |
14
|
|
|
use Bdf\Prime\Query\Compiler\SqlCompiler; |
15
|
|
|
use Bdf\Prime\Query\Custom\KeyValue\KeyValueQuery; |
16
|
|
|
use Bdf\Prime\Query\Custom\KeyValue\KeyValueSqlCompiler; |
17
|
|
|
use Bdf\Prime\Repository\EntityRepository; |
18
|
|
|
use Bdf\Prime\ServiceLocator; |
19
|
|
|
use Bdf\Prime\Types\ArrayType; |
20
|
|
|
use BenchCaseAdapter; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @Revs(100) |
24
|
|
|
* @Warmup(1) |
25
|
|
|
*/ |
26
|
|
|
class CompilerBench extends BenchCaseAdapter |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var ServiceLocator |
30
|
|
|
*/ |
31
|
|
|
protected $prime; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var BenchData |
35
|
|
|
*/ |
36
|
|
|
protected $data; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ArrayCache |
40
|
|
|
*/ |
41
|
|
|
protected $cache; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var EntityRepository |
45
|
|
|
*/ |
46
|
|
|
protected $repository; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var KeyValueSqlCompiler |
50
|
|
|
*/ |
51
|
|
|
protected $keyValueCompiler; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var SqlCompiler |
55
|
|
|
*/ |
56
|
|
|
protected $sqlCompiler; |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function setUp() |
61
|
|
|
{ |
62
|
|
|
$this->cache = new ArrayCache(); |
63
|
|
|
$this->prime = new ServiceLocator(); |
64
|
|
|
$this->prime->connections()->declareConnection('test', BENCH_CONNECTION); |
65
|
|
|
$this->prime->connection('test')->getConfiguration()->getTypes()->register(ArrayType::class, 'array'); |
|
|
|
|
66
|
|
|
Locatorizable::configure($this->prime); |
|
|
|
|
67
|
|
|
|
68
|
|
|
$this->data = new BenchData($this->prime); |
69
|
|
|
$this->data->register([User::class]); |
70
|
|
|
|
71
|
|
|
$this->repository = $this->prime->repository(User::class); |
72
|
|
|
|
73
|
|
|
$this->keyValueCompiler = new KeyValueSqlCompiler($this->repository->connection()); |
|
|
|
|
74
|
|
|
$this->sqlCompiler = new SqlCompiler($this->repository->connection()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
public function tearDown() |
81
|
|
|
{ |
82
|
|
|
$this->data->clear(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @Groups({"select"}) |
87
|
|
|
*/ |
88
|
|
|
public function bench_compileSelect_KeyValue() |
89
|
|
|
{ |
90
|
|
|
$query = $this->repository->connection()->make(KeyValueQuery::class, new OrmPreprocessor($this->repository)); |
91
|
|
|
$query->from($this->repository->metadata()->table); |
92
|
|
|
(new QueryRepositoryExtension($this->repository))->apply($query); |
93
|
|
|
|
94
|
|
|
$query->where(['name' => 'John', 'customer.id' => 5]); |
|
|
|
|
95
|
|
|
|
96
|
|
|
$this->keyValueCompiler->compileSelect($query); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @Groups({"delete"}) |
101
|
|
|
*/ |
102
|
|
|
public function bench_compileDelete_KeyValue() |
103
|
|
|
{ |
104
|
|
|
$query = $this->repository->connection()->make(KeyValueQuery::class, new OrmPreprocessor($this->repository)); |
105
|
|
|
$query->from($this->repository->metadata()->table); |
106
|
|
|
(new QueryRepositoryExtension($this->repository))->apply($query); |
107
|
|
|
|
108
|
|
|
$query->where(['name' => 'John', 'customer.id' => 5]); |
109
|
|
|
|
110
|
|
|
$this->keyValueCompiler->compileDelete($query); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @Groups({"select"}) |
115
|
|
|
*/ |
116
|
|
|
public function bench_compileSelect_default() |
117
|
|
|
{ |
118
|
|
|
$query = $this->repository->builder(); |
119
|
|
|
$query->where(['name' => 'John', 'customer.id' => 5]); |
120
|
|
|
|
121
|
|
|
$this->sqlCompiler->compileSelect($query); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @Groups({"delete"}) |
126
|
|
|
*/ |
127
|
|
|
public function bench_compileDelete_default() |
128
|
|
|
{ |
129
|
|
|
$query = $this->repository->builder(); |
130
|
|
|
$query->where(['name' => 'John', 'customer.id' => 5]); |
131
|
|
|
|
132
|
|
|
$this->sqlCompiler->compileDelete($query); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
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