[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 * 15 * This software consists of voluntary contributions made by many individuals 16 * and is licensed under the MIT license. 17 */ 18 19 namespace ProxyManagerTest\Functional; 20 21 /** 22 * Base performance test logic for lazy loading proxies 23 * 24 * @author Marco Pivetta <ocramius@gmail.com> 25 * @license MIT 26 * 27 * @group Performance 28 * @coversNothing 29 */ 30 abstract class BaseLazyLoadingPerformanceTest extends BasePerformanceTest 31 { 32 /** 33 * @param string $className 34 * @param object[] $instances 35 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies 36 * @param string $methodName 37 * @param array $parameters 38 */ 39 protected function profileMethodAccess($className, array $instances, array $proxies, $methodName, array $parameters) 40 { 41 $iterations = count($instances); 42 43 $this->startCapturing(); 44 45 foreach ($instances as $instance) { 46 call_user_func_array(array($instance, $methodName), $parameters); 47 } 48 49 $baseProfile = $this->endCapturing( 50 $iterations . ' calls to ' . $className . '#' . $methodName . ': %fms / %fKb' 51 ); 52 $this->startCapturing(); 53 54 foreach ($proxies as $proxy) { 55 call_user_func_array(array($proxy, $methodName), $parameters); 56 } 57 58 $proxyProfile = $this->endCapturing( 59 $iterations . ' calls to proxied ' . $className . '#' . $methodName . ': %fms / %fKb' 60 ); 61 $this->compareProfile($baseProfile, $proxyProfile); 62 } 63 64 /** 65 * @param string $className 66 * @param object[] $instances 67 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies 68 * @param string $property 69 */ 70 protected function profilePropertyWrites($className, array $instances, array $proxies, $property) 71 { 72 $iterations = count($instances); 73 74 $this->startCapturing(); 75 76 foreach ($instances as $instance) { 77 $instance->$property = 'foo'; 78 } 79 80 $baseProfile = $this->endCapturing( 81 $iterations . ' writes of ' . $className . '::' . $property . ': %fms / %fKb' 82 ); 83 $this->startCapturing(); 84 85 foreach ($proxies as $proxy) { 86 $proxy->$property = 'foo'; 87 } 88 89 $proxyProfile = $this->endCapturing( 90 $iterations . ' writes of proxied ' . $className . '::' . $property . ': %fms / %fKb' 91 ); 92 $this->compareProfile($baseProfile, $proxyProfile); 93 } 94 95 /** 96 * @param string $className 97 * @param object[] $instances 98 * @param \ProxyManager\Proxy\LazyLoadingInterface[] $proxies 99 * @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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |