From 41b3a372d3306cddfe54aeb3a085f8c5300dfcff Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei <kontakt@beberlei.de> Date: Sat, 30 Apr 2011 10:47:56 +0200 Subject: [PATCH] Add new performance test checking compute changeset performance. --- .../Performance/UnitOfWorkPerformanceTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php diff --git a/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php new file mode 100644 index 000000000..28d9ea6d3 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php @@ -0,0 +1,50 @@ +<?php + +namespace Doctrine\Tests\ORM\Performance; + +require_once __DIR__ . '/../../TestInit.php'; + +use Doctrine\Tests\Models\CMS\CmsUser; + +/** + * Description of InsertPerformanceTest + * + * @author robo + */ +class UnitOfWorkPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase +{ + protected function setUp() + { + $this->useModelSet('cms'); + parent::setUp(); + } + + public function testComputeChanges() + { + $n = 100; + + $users = array(); + for ($i=1; $i<=$n; ++$i) { + $user = new CmsUser; + $user->status = 'user'; + $user->username = 'user' . $i; + $user->name = 'Mr.Smith-' . $i; + $this->_em->persist($user); + $users[] = $user; + } + $this->_em->flush(); + + + foreach ($users AS $user) { + $user->status = 'other'; + $user->username = $user->username . '++'; + $user->name = str_replace('Mr.', 'Mrs.', $user->name); + } + + $s = microtime(true); + $this->_em->flush(); + $e = microtime(true); + + echo ' Compute ChangeSet '.$n.' objects in ' . ($e - $s) . ' seconds' . PHP_EOL; + } +} \ No newline at end of file