Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
BaseLazyLoadingPerformanceTest.php
001 <?php
002 /*
003 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
004 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
005 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
006 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
007 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
008 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
009 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
010 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
011 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
012 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
013 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014 *
015 * This software consists of voluntary contributions made by many individuals
016 * and is licensed under the MIT license.
017 */
018
019 namespace ProxyManagerTest\Functional;
020
021 /**
022 * Base performance test logic for lazy loading proxies
023 *
024 * @author Marco Pivetta <ocramius@gmail.com>
025 * @license MIT
026 *
027 * @group Performance
028 * @coversNothing
029 */
030 abstract class BaseLazyLoadingPerformanceTest extends BasePerformanceTest
031 {
032 /**
033 * @param string $className
034 * @param object[] $instances
035 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies
036 * @param string $methodName
037 * @param array $parameters
038 */
039 protected function profileMethodAccess($className, array $instances, array $proxies, $methodName, array $parameters)
040 {
041 $iterations = count($instances);
042
043 $this->startCapturing();
044
045 foreach ($instances as $instance) {
046 call_user_func_array(array($instance, $methodName), $parameters);
047 }
048
049 $baseProfile = $this->endCapturing(
050 $iterations . ' calls to ' . $className . '#' . $methodName . ': %fms / %fKb'
051 );
052 $this->startCapturing();
053
054 foreach ($proxies as $proxy) {
055 call_user_func_array(array($proxy, $methodName), $parameters);
056 }
057
058 $proxyProfile = $this->endCapturing(
059 $iterations . ' calls to proxied ' . $className . '#' . $methodName . ': %fms / %fKb'
060 );
061 $this->compareProfile($baseProfile, $proxyProfile);
062 }
063
064 /**
065 * @param string $className
066 * @param object[] $instances
067 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies
068 * @param string $property
069 */
070 protected function profilePropertyWrites($className, array $instances, array $proxies, $property)
071 {
072 $iterations = count($instances);
073
074 $this->startCapturing();
075
076 foreach ($instances as $instance) {
077 $instance->$property = 'foo';
078 }
079
080 $baseProfile = $this->endCapturing(
081 $iterations . ' writes of ' . $className . '::' . $property . ': %fms / %fKb'
082 );
083 $this->startCapturing();
084
085 foreach ($proxies as $proxy) {
086 $proxy->$property = 'foo';
087 }
088
089 $proxyProfile = $this->endCapturing(
090 $iterations . ' writes of proxied ' . $className . '::' . $property . ': %fms / %fKb'
091 );
092 $this->compareProfile($baseProfile, $proxyProfile);
093 }
094
095 /**
096 * @param string $className
097 * @param object[] $instances
098 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies
099 * @param string $property
100 */
101 protected function profilePropertyReads($className, array $instances, array $proxies, $property)
102 {
103 $iterations = count($instances);
104
105 $this->startCapturing();
106
107 foreach ($instances as $instance) {
108 $instance->$property;
109 }
110
111 $baseProfile = $this->endCapturing(
112 $iterations . ' reads of ' . $className . '::' . $property . ': %fms / %fKb'
113 );
114 $this->startCapturing();
115
116 foreach ($proxies as $proxy) {
117 $proxy->$property;
118 }
119
120 $proxyProfile = $this->endCapturing(
121 $iterations . ' reads of proxied ' . $className . '::' . $property . ': %fms / %fKb'
122 );
123 $this->compareProfile($baseProfile, $proxyProfile);
124 }
125
126 /**
127 * @param string $className
128 * @param object[] $instances
129 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies
130 * @param string $property
131 */
132 protected function profilePropertyIsset($className, array $instances, array $proxies, $property)
133 {
134 $iterations = count($instances);
135
136 $this->startCapturing();
137
138 foreach ($instances as $instance) {
139 isset($instance->$property);
140 }
141
142 $baseProfile = $this->endCapturing(
143 $iterations . ' isset of ' . $className . '::' . $property . ': %fms / %fKb'
144 );
145 $this->startCapturing();
146
147 foreach ($proxies as $proxy) {
148 isset($proxy->$property);
149 }
150
151 $proxyProfile = $this->endCapturing(
152 $iterations . ' isset of proxied ' . $className . '::' . $property . ': %fms / %fKb'
153 );
154 $this->compareProfile($baseProfile, $proxyProfile);
155 }
156
157 /**
158 * @param string $className
159 * @param object[] $instances
160 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies
161 * @param string $property
162 */
163 protected function profilePropertyUnset($className, array $instances, array $proxies, $property)
164 {
165 $iterations = count($instances);
166
167 $this->startCapturing();
168
169 foreach ($instances as $instance) {
170 unset($instance->$property);
171 }
172
173 $baseProfile = $this->endCapturing(
174 $iterations . ' unset of ' . $className . '::' . $property . ': %fms / %fKb'
175 );
176 $this->startCapturing();
177
178 foreach ($proxies as $proxy) {
179 unset($proxy->$property);
180 }
181
182 $proxyProfile = $this->endCapturing(
183 $iterations . ' unset of proxied ' . $className . '::' . $property . ': %fms / %fKb'
184 );
185 $this->compareProfile($baseProfile, $proxyProfile);
186 }
187
188 /**
189 * Generates a proxy for the given class name, and retrieves its class name
190 *
191 * @param string $parentClassName
192 *
193 * @return string
194 */
195 abstract protected function generateProxy($parentClassName);
196 }
197