Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Service manager performance optimized #4139

Conversation

Ocramius
Copy link
Member

This PR inlines some of the methods internal to the service manager. Following changes may be potential BC breaks:

  • canCreate has been deprecated (as it seems, it is an internal method anyway. Users should keep using has)
  • isSubclassOf has been deprecated (was used internally)
  • The canonical names map is re-used directly, instead of calling canonicalizeName each time

NOTE: if this one is ok, remove the performance test case before merging (or tell me to do so)

@Ocramius
Copy link
Member Author

No idea whatsoever why the build fails. Ok, @weierophinney found out it's an un-related problem with RandomLib going out of memory.

For comparison, here's the results over 100000 iterations:

  • Zend\ServiceManager\ServiceManager::get (with defined service):
    • before: 0.65002608299255
    • after: 0.2622389793396
  • Zend\ServiceManager\ServiceManager::has (with defined service):
    • before: 0.65546894073486
    • after: 0.33996605873108
  • Zend\ServiceManager\ServiceManager::has (without defined service):
    • before: 0.84106206893921
    • after: 0.517333984375
  • Zend\ServiceManager\ServiceManager::create (without defined invokable):
    • before: 0.79828000068665
    • after: 0.70576095581055

@mwillbanks
Copy link
Contributor

I see that also var_dump'd in the test... you may consider removing it :)

   [concat]                 ZendTest/ServiceManager
   [concat] 
   [concat]             PHPUnit 3.7.19 by Sebastian Bergmann.
   [concat] 
   [concat] Configuration read from /home/travis/build/zendframework/zf2/tests/phpunit.xml.dist
   [concat] 
   [concat] ........SS.string(73) "ZendTest\ServiceManager\ServiceManagerPerformanceTest::testGetPerformance"
   [concat] array(2) {
   [concat]   ["time"]=>
   [concat]   float(0.83468294143677)
   [concat]   ["iterations"]=>
   [concat]   int(100000)
   [concat] }
   [concat] .string(73) "ZendTest\ServiceManager\ServiceManagerPerformanceTest::testHasPerformance"
   [concat] array(2) {
   [concat]   ["time"]=>
   [concat]   float(1.0163159370422)
   [concat]   ["iterations"]=>
   [concat]   int(100000)
   [concat] }
   [concat] .string(86) "ZendTest\ServiceManager\ServiceManagerPerformanceTest::testHasPerformanceWithNoService"
   [concat] array(2) {
   [concat]   ["time"]=>
   [concat]   float(1.4539151191711)
   [concat]   ["iterations"]=>
   [concat]   int(100000)
   [concat] }
   [concat] .string(76) "ZendTest\ServiceManager\ServiceManagerPerformanceTest::testCreatePerformance"
   [concat] array(2) {
   [concat]   ["time"]=>
   [concat]   float(1.9051969051361)
   [concat]   ["iterations"]=>
   [concat]   int(100000)
   [concat] }
   [concat] ................................................... 65 / 74 ( 87%)
   [concat] .........
   [concat] 
   [concat] Time: 5 seconds, Memory: 11.25Mb
   [concat] 
   [concat] OK, but incomplete or skipped tests!
   [concat] Tests: 74, Assertions: 107, Skipped: 2.

@Ocramius
Copy link
Member Author

@mwillbanks yes, these performance tests are here for the only purpose of showing that it works. I noted that in the PR description

@ghost ghost assigned weierophinney Apr 11, 2013
weierophinney added a commit that referenced this pull request Apr 11, 2013
…mance-optimized

Service manager performance optimized
weierophinney added a commit that referenced this pull request Apr 11, 2013
@weierophinney weierophinney merged commit 89b6d01 into zendframework:develop Apr 11, 2013
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
…ture/service-manager-performance-optimized

Service manager performance optimized
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants