6
6
use MongoDB \Benchmark \BaseBench ;
7
7
use MongoDB \BSON \Document ;
8
8
use MongoDB \Driver \Command ;
9
- use MongoDB \Driver \WriteConcern ;
10
9
use PhpBench \Attributes \BeforeMethods ;
11
10
use PhpBench \Attributes \ParamProviders ;
12
11
use PhpBench \Attributes \Revs ;
15
14
use function file_get_contents ;
16
15
use function range ;
17
16
18
- /** @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#single-doc-benchmarks */
17
+ /**
18
+ * For accurate results, run benchmarks on a standalone server.
19
+ *
20
+ * @see https://github.com/mongodb/specifications/blob/ddfc8b583d49aaf8c4c19fa01255afb66b36b92e/source/benchmarking/benchmarking.rst#single-doc-benchmarks
21
+ */
19
22
#[BeforeMethods('prepareDatabase ' )]
20
23
final class SingleDocBench extends BaseBench
21
24
{
@@ -28,9 +31,10 @@ public function prepareDatabase(): void
28
31
public function benchRunCommand (): void
29
32
{
30
33
$ manager = self ::createClient ()->getManager ();
34
+ $ database = self ::getDatabase ();
31
35
32
36
for ($ i = 0 ; $ i < 10_000 ; $ i ++) {
33
- $ manager ->executeCommand (self :: getDatabase () , new Command (['hello ' => true ]));
37
+ $ manager ->executeCommand ($ database , new Command (['hello ' => true ]));
34
38
}
35
39
}
36
40
@@ -96,12 +100,6 @@ public static function provideInsertOneParams(): Generator
96
100
'repeat ' => 10_000 ,
97
101
];
98
102
99
- yield 'Small doc WC 0 ' => [
100
- 'document ' => self ::readJsonFile (self ::SMALL_FILE_PATH ),
101
- 'repeat ' => 10_000 ,
102
- 'options ' => ['writeConcern ' => new WriteConcern (0 )],
103
- ];
104
-
105
103
yield 'Large doc ' => [
106
104
'document ' => self ::readJsonFile (self ::LARGE_FILE_PATH ),
107
105
'repeat ' => 10 ,
@@ -111,11 +109,5 @@ public static function provideInsertOneParams(): Generator
111
109
'document ' => Document::fromJSON (file_get_contents (self ::LARGE_FILE_PATH )),
112
110
'repeat ' => 10 ,
113
111
];
114
-
115
- yield 'Large doc WC 0 ' => [
116
- 'document ' => Document::fromJSON (file_get_contents (self ::LARGE_FILE_PATH )),
117
- 'repeat ' => 10 ,
118
- 'options ' => ['writeConcern ' => new WriteConcern (0 )],
119
- ];
120
112
}
121
113
}
0 commit comments