This repository was archived by the owner on Feb 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathFetchServices.php
84 lines (73 loc) · 1.86 KB
/
FetchServices.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace ZendBench\ServiceManager;
use Athletic\AthleticEvent;
use Zend\ServiceManager\ServiceManager;
class FetchServices extends AthleticEvent
{
const NUM_SERVICES = 1000;
/**
* @var ServiceManager
*/
protected $sm;
protected function getConfig()
{
$config = [];
for ($i = 0; $i <= self::NUM_SERVICES; $i++) {
$config['factories']["factory_$i"] = BenchAsset\FactoryFoo::class;
$config['invokables']["invokable_$i"] = BenchAsset\Foo::class;
$config['services']["service_$i"] = $this;
$config['aliases']["alias_$i"] = "service_$i";
}
$config['abstract_factories'] = [ BenchAsset\AbstractFactoryFoo::class ];
return $config;
}
public function classSetUp()
{
$this->sm = new ServiceManager($this->getConfig());
}
/**
* Fetch the factory services
*
* @iterations 5000
*/
public function fetchFactoryService()
{
$result = $this->sm->get('factory_' . rand(0, self::NUM_SERVICES));
}
/**
* Fetch the invokable services
*
* @iterations 5000
*/
public function fetchInvokableService()
{
$result = $this->sm->get('invokable_' . rand(0, self::NUM_SERVICES));
}
/**
* Fetch the services
*
* @iterations 5000
*/
public function fetchService()
{
$result = $this->sm->get('service_' . rand(0, self::NUM_SERVICES));
}
/**
* Fetch the alias services
*
* @iterations 5000
*/
public function fetchAliasService()
{
$result = $this->sm->get('alias_' . rand(0, self::NUM_SERVICES));
}
/**
* Fetch the abstract factory services
*
* @iterations 5000
*/
public function fetchAbstractFactoryService()
{
$result = $this->sm->get('foo');
}
}