1- const { Readable } = require ( 'stream' ) ;
2- const { pipeline } = require ( 'stream/promises' ) ;
31const {
4- loadSpecFile,
52 makeLoadJSON,
63 makeClient,
74 connectClient,
85 initDb,
96 dropDb,
107 initCollection,
118 makeLoadTweets,
12- disconnectClient,
13- makeLoadInsertDocs,
14- createCollection,
15- dropCollection,
16- dropBucket,
17- initBucket,
18- writeSingleByteFileToBucket
9+ disconnectClient
1910} = require ( '../../driverBench/common' ) ;
2011
21- function loadGridFs ( ) {
22- this . bin = loadSpecFile ( [ 'single_and_multi_document' , 'gridfs_large.bin' ] ) ;
23- }
24-
25- function gridFsInitUploadStream ( ) {
26- this . uploadStream = this . bucket . openUploadStream ( 'gridfstest' ) ;
27- }
28-
29- async function gridFsUpload ( ) {
30- const uploadData = Readable . from ( this . bin ) ;
31- const uploadStream = this . uploadStream ;
32- await pipeline ( uploadData , uploadStream ) ;
33- }
34-
3512function makeMultiBench ( suite ) {
3613 return suite
37- . benchmark ( 'findManyAndEmptyCursor ' , benchmark =>
14+ . benchmark ( 'findManyAndToArrayOld ' , benchmark =>
3815 benchmark
3916 . taskSize ( 16.22 )
4017 . setup ( makeLoadJSON ( 'tweet.json' ) )
@@ -45,102 +22,44 @@ function makeMultiBench(suite) {
4522 . setup ( initCollection )
4623 . setup ( makeLoadTweets ( false ) )
4724 . task ( async function ( ) {
48- // eslint-disable-next-line no-unused-vars
49- for await ( const _ of this . collection . find ( { } ) ) {
50- // do nothing
51- }
25+ await this . collection . find ( { } ) . toArrayOld ( ) ;
5226 } )
5327 . teardown ( dropDb )
5428 . teardown ( disconnectClient )
5529 )
56- . benchmark ( 'smallDocBulkInsert ' , benchmark =>
30+ . benchmark ( 'findManyAndToArray ' , benchmark =>
5731 benchmark
58- . taskSize ( 2.75 )
59- . setup ( makeLoadJSON ( 'small_doc.json' ) )
60- . setup ( makeLoadInsertDocs ( 10000 ) )
32+ . taskSize ( 16.22 )
33+ . setup ( makeLoadJSON ( 'tweet.json' ) )
6134 . setup ( makeClient )
6235 . setup ( connectClient )
6336 . setup ( initDb )
6437 . setup ( dropDb )
65- . setup ( initDb )
6638 . setup ( initCollection )
67- . setup ( createCollection )
68- . beforeTask ( dropCollection )
69- . beforeTask ( createCollection )
70- . beforeTask ( initCollection )
71- . task ( async function ( ) {
72- await this . collection . insertMany ( this . docs , { ordered : true } ) ;
73- } )
74- . teardown ( dropDb )
75- . teardown ( disconnectClient )
76- )
77- . benchmark ( 'largeDocBulkInsert' , benchmark =>
78- benchmark
79- . taskSize ( 27.31 )
80- . setup ( makeLoadJSON ( 'large_doc.json' ) )
81- . setup ( makeLoadInsertDocs ( 10 ) )
82- . setup ( makeClient )
83- . setup ( connectClient )
84- . setup ( initDb )
85- . setup ( dropDb )
86- . setup ( initDb )
87- . setup ( initCollection )
88- . setup ( createCollection )
89- . beforeTask ( dropCollection )
90- . beforeTask ( createCollection )
91- . beforeTask ( initCollection )
39+ . setup ( makeLoadTweets ( false ) )
9240 . task ( async function ( ) {
93- await this . collection . insertMany ( this . docs , { ordered : true } ) ;
41+ await this . collection . find ( { } ) . toArray ( ) ;
9442 } )
9543 . teardown ( dropDb )
9644 . teardown ( disconnectClient )
9745 )
98- . benchmark ( 'gridFsUpload' , benchmark =>
99- benchmark
100- . taskSize ( 52.43 )
101- . setup ( loadGridFs )
102- . setup ( makeClient )
103- . setup ( connectClient )
104- . setup ( initDb )
105- . setup ( dropDb )
106- . setup ( initDb )
107- . setup ( initCollection )
108- . beforeTask ( dropBucket )
109- . beforeTask ( initBucket )
110- . beforeTask ( gridFsInitUploadStream )
111- . beforeTask ( writeSingleByteFileToBucket )
112- . task ( gridFsUpload )
113- . teardown ( dropDb )
114- . teardown ( disconnectClient )
115- )
116- . benchmark ( 'gridFsDownload' , benchmark =>
46+ . benchmark ( 'findManyAndToArrayOldWithTransform' , benchmark =>
11747 benchmark
118- . taskSize ( 52.43 )
119- . setup ( loadGridFs )
48+ . taskSize ( 16.22 )
49+ . setup ( makeLoadJSON ( 'tweet.json' ) )
12050 . setup ( makeClient )
12151 . setup ( connectClient )
12252 . setup ( initDb )
12353 . setup ( dropDb )
124- . setup ( initDb )
12554 . setup ( initCollection )
126- . setup ( dropBucket )
127- . setup ( initBucket )
128- . setup ( gridFsInitUploadStream )
129- . setup ( async function ( ) {
130- await gridFsUpload . call ( this ) ;
131- this . id = this . uploadStream . id ;
132- this . uploadData = undefined ;
133- } )
55+ . setup ( makeLoadTweets ( false ) )
13456 . task ( async function ( ) {
135- // eslint-disable-next-line no-unused-vars
136- for await ( const _ of this . bucket . openDownloadStream ( this . id ) ) {
137- // do nothing
138- }
57+ await this . collection . find ( { } ) . toArrayOld ( doc => [ doc , doc ] ) ;
13958 } )
14059 . teardown ( dropDb )
14160 . teardown ( disconnectClient )
14261 )
143- . benchmark ( 'findManyAndToArray ' , benchmark =>
62+ . benchmark ( 'findManyAndToArrayWithTransform ' , benchmark =>
14463 benchmark
14564 . taskSize ( 16.22 )
14665 . setup ( makeLoadJSON ( 'tweet.json' ) )
@@ -151,7 +70,7 @@ function makeMultiBench(suite) {
15170 . setup ( initCollection )
15271 . setup ( makeLoadTweets ( false ) )
15372 . task ( async function ( ) {
154- await this . collection . find ( { } ) . toArray ( ) ;
73+ await this . collection . find ( { } ) . toArray ( doc => [ doc , doc ] ) ;
15574 } )
15675 . teardown ( dropDb )
15776 . teardown ( disconnectClient )
0 commit comments