5
5
use Generator ;
6
6
use MongoDB \Benchmark \BaseBench ;
7
7
use MongoDB \BSON \Document ;
8
+ use MongoDB \Driver \Command ;
8
9
use PhpBench \Attributes as Bench ;
9
10
10
11
use function array_map ;
@@ -20,6 +21,16 @@ public function prepareDatabase(): void
20
21
self ::getCollection ()->drop ();
21
22
}
22
23
24
+ /** @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#run-command */
25
+ public function benchRunCommand (): void
26
+ {
27
+ $ manager = self ::createClient ()->getManager ();
28
+
29
+ for ($ i = 0 ; $ i < 10_000 ; $ i ++) {
30
+ $ manager ->executeCommand (self ::getDatabase (), new Command (['hello ' => true ]));
31
+ }
32
+ }
33
+
23
34
public function setupFindOneById (): void
24
35
{
25
36
$ tweet = self ::readJsonFile (self ::TWEET_FILE_PATH );
@@ -38,7 +49,10 @@ public static function provideFindOneByIdParams(): Generator
38
49
];
39
50
}
40
51
41
- /** @param array{options: array} $params */
52
+ /**
53
+ * @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#find-one-by-id
54
+ * @param array{options: array} $params
55
+ */
42
56
#[Bench \BeforeMethods('setupFindOneById ' )]
43
57
#[Bench \ParamProviders('provideFindOneByIdParams ' )]
44
58
#[Bench \Revs(1 )]
@@ -74,7 +88,11 @@ public static function provideInsertOneParams(): Generator
74
88
];
75
89
}
76
90
77
- /** @param array{document: object|array, repeat: int} $params */
91
+ /**
92
+ * @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#small-doc-insertone
93
+ * @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#large-doc-bulk-insert
94
+ * @param array{document: object|array, repeat: int} $params
95
+ */
78
96
#[Bench \ParamProviders('provideInsertOneParams ' )]
79
97
#[Bench \Revs(1 )]
80
98
public function benchInsertOne (array $ params ): void
0 commit comments