-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
142 lines (113 loc) · 5 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
include './vendor/autoload.php';
ini_set('memory_limit', -1); // no memory limit
use Atlas\Orm\Atlas;
var_dump('atlas/orm', \Composer\InstalledVersions::getVersion('atlas/orm'));
var_dump('doctrine/orm', \Composer\InstalledVersions::getVersion('doctrine/orm'));
var_dump('illuminate/database', \Composer\InstalledVersions::getVersion('illuminate/database'));
var_dump('rotexsoft/leanorm', \Composer\InstalledVersions::getVersion('rotexsoft/leanorm'));
var_dump('gabordemooij/redbean', \Composer\InstalledVersions::getVersion('gabordemooij/redbean'));
$ubench = new Ubench();
\Rotexsoft\PhpOrmBenchmarks\BootstrapEloquent::setup();
$atlasSettings = require_once './atlas.php';
echo 'PDO Config'. PHP_EOL;
var_dump($atlasSettings['pdo']);
$leanArgs = $atlasSettings['pdo'];
$leanArgs[1] ??= '';
$leanArgs[2] ??= '';
$leanOrmAuthors = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\Authors\AuthorsModel(...$leanArgs);
$leanOrmComments = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\Comments\CommentsModel(...$leanArgs);
$leanOrmPosts = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\Posts\PostsModel(...$leanArgs);
$leanOrmPostsTags = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\PostsTags\PostsTagsModel(...$leanArgs);
$leanOrmSummaries = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\Summaries\SummariesModel(...$leanArgs);
$leanOrmTags = new \Rotexsoft\PhpOrmBenchmarks\LeanOrm\Blog\Tags\TagsModel(...$leanArgs);
$atlas = Atlas::new(
$atlasSettings['pdo'][0],
$atlasSettings['pdo'][1],
$atlasSettings['pdo'][2]
);
$benchAtlasHasManyOrHasManyThrough =
new Rotexsoft\PhpOrmBenchmarks\Ubench\AtlasHasManyOrHasManyThroughRunner();
$benchEloquentHasManyOrHasManyThrough =
new Rotexsoft\PhpOrmBenchmarks\Ubench\EloquentHasManyOrHasManyThroughRunner();
$benchLeanHasManyOrHasManyThrough =
new \Rotexsoft\PhpOrmBenchmarks\Ubench\LeanOrmHasManyOrHasManyThroughRunner();
$benchEloquentHasManyOrHasManyThrough(
$ubench,
\Rotexsoft\PhpOrmBenchmarks\Eloquent\Blog\Post::class,
'tags',
'post_id',
0,
1_000
);
echo 'Eloquent Posts with Tags (HasManyThrough) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
$benchLeanHasManyOrHasManyThrough(
$ubench,
$leanOrmPosts,
'tags',
'post_id',
0,
1_000
);
echo 'LeanORM Post with Tags (HasManyThrough) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
exit;
if(true) {
$benchAtlasHasManyOrHasManyThrough(
$ubench, $atlas, Rotexsoft\PhpOrmBenchmarks\AtlasOrm\Blog\Author\Author::class,
'posts', // relation name (has many or has many through)
'author_id', // parent record property to access
0, // offset
999 // limit
);
echo 'Atlas Authors with Posts (HasMany) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
$benchLeanHasManyOrHasManyThrough(
$ubench,
$leanOrmAuthors,
'posts',
'author_id',
0,
999
);
echo 'LeanORM Authors with Posts (HasMany) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
$benchEloquentHasManyOrHasManyThrough(
$ubench,
\Rotexsoft\PhpOrmBenchmarks\Eloquent\Blog\Author::class,
'posts',
'author_id',
0,
999
);
echo 'Eloquent Authors with Posts (HasMany) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
$benchLeanHasManyOrHasManyThrough(
$ubench,
$leanOrmPosts,
'tags',
'post_id',
0,
50_000
);
echo 'LeanORM Post with Tags (HasManyThrough) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
// $benchAtlasHasManyOrHasManyThrough(
// $ubench, $atlas, Rotexsoft\PhpOrmBenchmarks\AtlasOrm\Blog\Post\Post::class,
// 'tags', // relation name (has many or has many through)
// 'title', // parent record property to access
// 0, // offset
// 100 // limit
// );
// echo 'Atlas Post with Tags (HasManyThrough) ' . $ubench->getTime() . ' ' . $ubench->getMemoryUsage() . ' ' . $ubench->getMemoryPeak() . PHP_EOL. PHP_EOL;
} // if(true|false)
//$atlasToLeanOrmDataComparator = new \Rotexsoft\PhpOrmBenchmarks\AtlasToLeanOrmDataComparator();
//
//// test that author->posts fetched by leanOrm & Atlas match for each author
//$atlasToLeanOrmDataComparator->ensureHasManyOrHasManyThroughDataAreEqual(
// $atlas,
// \Rotexsoft\PhpOrmBenchmarks\AtlasOrm\Blog\Author\Author::class,
// $leanOrmAuthors,
// 'author_id',
// 'posts',
// 'Author',
// 'title', // for each author, get all the titles for each of author's posts
// // retrieved by atlas & lean, sort the titles & make sure they match
// 0, // offset
// 50_000 // limit
//);