forked from doctrine/mongodb-odm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitOfWorkPerformanceTest.php
40 lines (34 loc) · 1.02 KB
/
UnitOfWorkPerformanceTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Doctrine\Tests\ODM\MongoDB\Performance;
use Documents\CmsUser;
/**
* @group performance
*/
class UnitOfWorkPerformanceTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
/**
* [jwage: compute changesets for 10000 objects in ~10 seconds]
*/
public function testComputeChanges()
{
$users = array();
for ($i = 1; $i <= 10000; ++$i) {
$user = new CmsUser;
$user->status = 'user';
$user->username = 'user' . $i;
$user->name = 'Mr.Smith-' . $i;
$this->dm->persist($user);
$users[] = $user;
}
$this->dm->flush();
foreach ($users as $user) {
$user->status = 'other';
$user->username = $user->username . '++';
$user->name = str_replace('Mr.', 'Mrs.', $user->name);
}
$s = microtime(true);
$this->dm->flush();
$e = microtime(true);
echo 'Compute ChangeSet '.$n.' objects in ' . ($e - $s) . ' seconds' . PHP_EOL;
}
}