This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
778 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor | ||
composer.lock | ||
data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ before_script: | |
|
||
script: | ||
- phpunit | ||
- php ./vendor/bin/phpbench tests/benchmark | ||
|
||
notifications: | ||
slack: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use Sulu\Component\DocumentManager\Tests\Bootstrap; | ||
use Symfony\Component\Console\Helper\HelperSet; | ||
use Symfony\Component\Console\Application; | ||
|
||
require_once(__DIR__ . '/../vendor/autoload.php'); | ||
|
||
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( | ||
'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper(Bootstrap::createDbalConnection()) | ||
)); | ||
|
||
$cli = new Application('Sulu Document Manager Test CLI', '0.1'); | ||
$cli->setCatchExceptions(true); | ||
$cli->setHelperSet($helperSet); | ||
$cli->addCommands(array( | ||
new \Jackalope\Tools\Console\Command\InitDoctrineDbalCommand(), | ||
)); | ||
$cli->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<!-- Core --> | ||
<service id="sulu_document_manager.event_dispatcher.debug" class="Sulu\Component\DocumentManager\EventDispatcher\DebugEventDispatcher" public="false"> | ||
<argument type="service" id="service_container" /> | ||
<argument type="service" id="debug.stopwatch" /> | ||
<argument type="service" id="logger" /> | ||
<tag name="monolog.logger" channel="sulu_document_manager" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.event_dispatcher.standard" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher" public="false"> | ||
<argument type="service" id="service_container" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.document_manager" class="Sulu\Component\DocumentManager\DocumentManager"> | ||
<argument type="service" id="sulu_document_manager.event_dispatcher" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.document_registry" class="Sulu\Component\DocumentManager\DocumentRegistry" public="false"> | ||
<argument>%sulu_document_manager.default_locale%</argument> | ||
</service> | ||
|
||
<service id="sulu_document_manager.node_manager" class="Sulu\Component\DocumentManager\NodeManager" public="false"> | ||
<argument type="service" id="doctrine_phpcr.default_session" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.metadata_factory.base" class="Sulu\Component\DocumentManager\Metadata\BaseMetadataFactory" public="false"> | ||
<argument>%sulu_document_manager.mapping%</argument> | ||
</service> | ||
|
||
<service id="sulu_document_manager.metadata_factory" class="Sulu\Component\DocumentManager\Metadata\MetadataFactory" public="false"> | ||
<argument type="service" id="sulu_document_manager.metadata_factory.base" /> | ||
<argument type="service" id="sulu_document_manager.document_strategy" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.slugifier" class="Symfony\Cmf\Bundle\CoreBundle\Slugifier\CallbackSlugifier" public="false"> | ||
<argument>Ferrandini\Urlizer::urlize</argument> | ||
</service> | ||
|
||
<service id="sulu_document_manager.namespace_registry" class="Sulu\Component\DocumentManager\NamespaceRegistry" public="false"> | ||
<argument>%sulu_document_manager.namespace_mapping%</argument> | ||
</service> | ||
|
||
<service id="sulu_document_manager.property_encoder" class="Sulu\Component\DocumentManager\PropertyEncoder" public="false"> | ||
<argument type="service" id="sulu_document_manager.namespace_registry" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.name_resolver" class="Sulu\Component\DocumentManager\NameResolver" public="false" /> | ||
|
||
<service id="sulu_document_manager.document_strategy" class="Sulu\Component\DocumentManager\Strategy\MixinStrategy"> | ||
<argument type="service" id="sulu_document_manager.metadata_factory.base" /> | ||
</service> | ||
|
||
<!-- Utilities --> | ||
<service id="sulu_document_manager.path_segment_registry" class="Sulu\Component\DocumentManager\PathSegmentRegistry"> | ||
<argument type="collection"> | ||
</argument> | ||
</service> | ||
|
||
<service id="sulu_document_manager.document_inspector" class="Sulu\Component\DocumentManager\DocumentInspector"> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<argument type="service" id="sulu_document_manager.path_segment_registry" /> | ||
<argument type="service" id="sulu_document_manager.proxy_factory" /> | ||
</service> | ||
|
||
<!-- Proxy manager --> | ||
<service id="sulu_document_manager.proxy_factory" class="Sulu\Component\DocumentManager\ProxyFactory"> | ||
<argument type="service" id="sulu_document_manager.proxy_manager.factory.ghost" /> | ||
<argument type="service" id="sulu_document_manager.event_dispatcher" /> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<argument type="service" id="sulu_document_manager.metadata_factory" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.proxy_manager.factory.ghost" class="ProxyManager\Factory\LazyLoadingGhostFactory" /> | ||
|
||
</services> | ||
|
||
</container> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
|
||
<!-- Behavior Subscribers !--> | ||
<service id="sulu_document_manager.subscriber.behavior.auto_name" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Path\AutoNameSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<argument type="service" id="sulu_document_manager.slugifier" /> | ||
<argument type="service" id="sulu_document_manager.name_resolver" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<argument type="service" id="sulu_document_manager.document_strategy" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.behavior.path.explicit" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Path\ExplicitSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_strategy" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.timestamp" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Audit\TimestampSubscriber"> | ||
<argument type="service" id="sulu_document_manager.property_encoder" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.node_name" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\NodeNameSubscriber"> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.uuid" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\UuidSubscriber"> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.locale" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\LocaleSubscriber"> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.parent" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\ParentSubscriber"> | ||
<argument type="service" id="sulu_document_manager.proxy_factory" /> | ||
<argument type="service" id="sulu_document_manager.document_inspector" /> | ||
<argument type="service" id="sulu_document_manager.document_manager" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.suscriber.behavior.children" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\ChildrenSubscriber"> | ||
<argument type="service" id="sulu_document_manager.proxy_factory" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.behavior.path" class="Sulu\Component\DocumentManager\Subscriber\Behavior\Mapping\PathSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_inspector" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<!-- Core Subscribers --> | ||
<service id="sulu_document_manager.subscriber.core.instantiator" class="Sulu\Component\DocumentManager\Subscriber\Core\InstantiatorSubscriber"> | ||
<argument type="service" id="sulu_document_manager.metadata_factory" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.core.registrator" class="Sulu\Component\DocumentManager\Subscriber\Core\RegistratorSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.phpcr.reorder" class="Sulu\Component\DocumentManager\Subscriber\Phpcr\ReorderSubscriber"> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<!-- PHPCR subscribers --> | ||
<service id="sulu_document_manager.subscriber.phpcr.find" class="Sulu\Component\DocumentManager\Subscriber\Phpcr\FindSubscriber"> | ||
<argument type="service" id="sulu_document_manager.metadata_factory" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<argument type="service" id="sulu_document_manager.event_dispatcher" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.phpcr.query" class="Sulu\Component\DocumentManager\Subscriber\Phpcr\QuerySubscriber"> | ||
<argument type="service" id="doctrine_phpcr.default_session" /> | ||
<argument type="service" id="sulu_document_manager.event_dispatcher" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.phpcr.general" class="Sulu\Component\DocumentManager\Subscriber\Phpcr\GeneralSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<argument type="service" id="sulu_document_manager.event_dispatcher" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
<service id="sulu_document_manager.subscriber.phpcr.remove" class="Sulu\Component\DocumentManager\Subscriber\Phpcr\RemoveSubscriber"> | ||
<argument type="service" id="sulu_document_manager.document_registry" /> | ||
<argument type="service" id="sulu_document_manager.node_manager" /> | ||
<tag name="sulu_document_manager.event_subscriber" /> | ||
</service> | ||
|
||
</services> | ||
|
||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sulu CMS. | ||
* | ||
* (c) MASSIVE ART WebServices GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Component\DocumentManager\Tests\Bench; | ||
|
||
use Sulu\Component\DocumentManager\Tests\Bootstrap; | ||
use Sulu\Component\DocumentManager\Subscriber\Behavior; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
use PhpBench\BenchCase; | ||
|
||
abstract class BaseBench implements BenchCase | ||
{ | ||
const BASE_NAME = 'test'; | ||
const BASE_PATH = '/' . self::BASE_NAME; | ||
|
||
private $session; | ||
private $container; | ||
|
||
protected function initPhpcr() | ||
{ | ||
$session = $this->getSession(); | ||
|
||
if ($session->getRootNode()->hasNode(self::BASE_NAME)) { | ||
$session->removeItem(self::BASE_PATH); | ||
$session->save(); | ||
} | ||
|
||
$session->getRootNode()->addNode(self::BASE_NAME); | ||
} | ||
|
||
protected function getContainer() | ||
{ | ||
if ($this->container) { | ||
return $this->container; | ||
} | ||
|
||
$this->container = Bootstrap::createContainer(); | ||
|
||
return $this->container; | ||
} | ||
|
||
protected function getSession() | ||
{ | ||
$session = $this->getContainer()->get('doctrine_phpcr.default_session'); | ||
return $session; | ||
} | ||
|
||
protected function getDocumentManager() | ||
{ | ||
return $this->getContainer()->get('sulu_document_manager.document_manager'); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sulu CMS. | ||
* | ||
* (c) MASSIVE ART WebServices GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Component\DocumentManager\Tests\Bench; | ||
|
||
use PhpBench\BenchCase; | ||
use PhpBench\BenchIteration; | ||
|
||
class BenchmarkBench extends BaseBench | ||
{ | ||
public function init() | ||
{ | ||
$this->initPhpcr(); | ||
} | ||
|
||
/** | ||
* @description persist and find nodes using the Document Manager | ||
* @iterations 1 | ||
* @paramProvider provideNodeTotals | ||
* @paramProvider provideLocales | ||
* @beforeMethod init | ||
*/ | ||
public function benchCreatePersist(BenchIteration $iteration) | ||
{ | ||
$manager = $this->getDocumentManager(); | ||
$locales = $iteration->getParameter('locales'); | ||
|
||
for ($i = 0; $i < $iteration->getParameter('nb_nodes'); $i++) { | ||
$document = $manager->create('full'); | ||
foreach ($locales as $locale) { | ||
$manager->persist($document, $locale, array( | ||
'path' => self::BASE_PATH . '/node-' . $i | ||
)); | ||
} | ||
} | ||
|
||
$manager->flush(); | ||
} | ||
|
||
/** | ||
* @description persist and find nodes using raw PHPCR | ||
* @iterations 4 | ||
* @paramProvider provideNodeTotals | ||
* @paramProvider provideLocales | ||
* @beforeMethod init | ||
*/ | ||
public function benchCreatePersistPhpcr(BenchIteration $iteration) | ||
{ | ||
$session = $this->getSession(); | ||
$baseNode = $session->getNode(self::BASE_PATH); | ||
|
||
for ($i = 0; $i < $iteration->getParameter('nb_nodes'); $i++) { | ||
$node = $baseNode->addNode('node-' . $i); | ||
foreach ($iteration->getParameter('locales') as $locale) { | ||
$node->addMixin('mix:test'); | ||
$node->setProperty('lsys:' . $locale .'-created', new \DateTime()); | ||
$node->setProperty('lsys:' . $locale .'-changed', new \DateTime()); | ||
} | ||
} | ||
|
||
$session->save(); | ||
} | ||
|
||
public function provideNodeTotals() | ||
{ | ||
return array( | ||
array( | ||
'nb_nodes' => 1, | ||
), | ||
array( | ||
'nb_nodes' => 10, | ||
), | ||
array( | ||
'nb_nodes' => 100, | ||
), | ||
); | ||
} | ||
|
||
public function provideLocales() | ||
{ | ||
return array( | ||
array( | ||
'locales' => array('en'), | ||
), | ||
array( | ||
'locales' => array('en', 'de'), | ||
), | ||
array( | ||
'locales' => array('en', 'de', 'fr'), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.