Skip to content

Commit 7b5a9c0

Browse files
stray change removal
1 parent 2b82d72 commit 7b5a9c0

File tree

5 files changed

+78
-152
lines changed

5 files changed

+78
-152
lines changed

results.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"info": {
4+
"test_name": "findManyAndToArrayOld",
5+
"tags": [
6+
"js-bson"
7+
]
8+
},
9+
"metrics": [
10+
{
11+
"name": "megabytes_per_second",
12+
"value": 88.05271598139723
13+
}
14+
]
15+
},
16+
{
17+
"info": {
18+
"test_name": "findManyAndToArray",
19+
"tags": [
20+
"js-bson"
21+
]
22+
},
23+
"metrics": [
24+
{
25+
"name": "megabytes_per_second",
26+
"value": 89.03528881742793
27+
}
28+
]
29+
},
30+
{
31+
"info": {
32+
"test_name": "findManyAndToArrayOldWithTransform",
33+
"tags": [
34+
"js-bson"
35+
]
36+
},
37+
"metrics": [
38+
{
39+
"name": "megabytes_per_second",
40+
"value": 86.97311297516816
41+
}
42+
]
43+
},
44+
{
45+
"info": {
46+
"test_name": "findManyAndToArrayWithTransform",
47+
"tags": [
48+
"js-bson"
49+
]
50+
},
51+
"metrics": [
52+
{
53+
"name": "megabytes_per_second",
54+
"value": 89.91431914455787
55+
}
56+
]
57+
}
58+
]

src/cursor/abstract_cursor.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,8 @@ export abstract class AbstractCursor<
457457
* results when this cursor had been previously accessed. In that case,
458458
* cursor.rewind() can be used to reset the cursor.
459459
*/
460-
async toArray(transform_temp?: (doc: TSchema) => any): Promise<TSchema[]> {
460+
async toArray(): Promise<TSchema[]> {
461461
const array: TSchema[] = [];
462-
463-
this.transform = transform_temp;
464462
// at the end of the loop (since readBufferedDocuments is called) the buffer will be empty
465463
// then, the 'await of' syntax will run a getMore call
466464
for await (const document of this) {

test/benchmarks/driverBench/index.js

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let bsonType = 'js-bson';
1010

1111
const { inspect } = require('util');
1212
const { writeFile } = require('fs/promises');
13-
const { makeParallelBenchmarks, makeSingleBench, makeMultiBench } = require('../mongoBench/suites');
13+
const { makeMultiBench } = require('../mongoBench/suites');
1414

1515
const hw = os.cpus();
1616
const ram = os.totalmem() / 1024 ** 3;
@@ -26,61 +26,12 @@ const systemInfo = () =>
2626
].join('\n');
2727
console.log(systemInfo());
2828

29-
function average(arr) {
30-
return arr.reduce((x, y) => x + y, 0) / arr.length;
31-
}
32-
33-
const benchmarkRunner = new Runner()
34-
.suite('singleBench', suite => makeSingleBench(suite))
35-
.suite('multiBench', suite => makeMultiBench(suite))
36-
.suite('parallel', suite => makeParallelBenchmarks(suite));
29+
const benchmarkRunner = new Runner().suite('multiBench', suite => makeMultiBench(suite));
3730

3831
benchmarkRunner
3932
.run()
4033
.then(microBench => {
41-
const singleBench = average([
42-
microBench.singleBench.findOne,
43-
microBench.singleBench.smallDocInsertOne,
44-
microBench.singleBench.largeDocInsertOne
45-
]);
46-
const multiBench = average(Object.values(microBench.multiBench));
47-
48-
const parallelBench = average([
49-
microBench.parallel.ldjsonMultiFileUpload,
50-
microBench.parallel.ldjsonMultiFileExport,
51-
microBench.parallel.gridfsMultiFileUpload,
52-
microBench.parallel.gridfsMultiFileDownload
53-
]);
54-
55-
const readBench = average([
56-
microBench.singleBench.findOne,
57-
microBench.multiBench.findManyAndEmptyCursor,
58-
microBench.multiBench.gridFsDownload,
59-
microBench.parallel.gridfsMultiFileDownload,
60-
microBench.parallel.ldjsonMultiFileExport
61-
]);
62-
const writeBench = average([
63-
microBench.singleBench.smallDocInsertOne,
64-
microBench.singleBench.largeDocInsertOne,
65-
microBench.multiBench.smallDocBulkInsert,
66-
microBench.multiBench.largeDocBulkInsert,
67-
microBench.multiBench.gridFsUpload,
68-
microBench.parallel.ldjsonMultiFileUpload,
69-
microBench.parallel.gridfsMultiFileUpload
70-
]);
71-
72-
const driverBench = average([readBench, writeBench]);
73-
7434
const benchmarkResults = {
75-
singleBench,
76-
multiBench,
77-
parallelBench,
78-
readBench,
79-
writeBench,
80-
driverBench,
81-
...microBench.parallel,
82-
...microBench.bsonBench,
83-
...microBench.singleBench,
8435
...microBench.multiBench
8536
};
8637

test/benchmarks/mongoBench/suites/multiBench.js

Lines changed: 15 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
1-
const { Readable } = require('stream');
2-
const { pipeline } = require('stream/promises');
31
const {
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-
3512
function 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)

test/tools/cluster_setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ elif [[ $1 == "sharded_cluster" ]]; then
2121
echo "mongodb://bob:pwd123@localhost:51000,localhost:51001"
2222
elif [[ $1 == "server" ]]; then
2323
mkdir -p $SINGLE_DIR
24-
mlaunch init --dir $SINGLE_DIR --ipv6 --auth --username "bob" --password "pwd123" --single --setParameter enableTestCommands=1
25-
echo "mongodb://bob:pwd123@localhost:27017"
24+
mlaunch init --dir $SINGLE_DIR --ipv6 --single --setParameter enableTestCommands=1
25+
echo "mongodb://localhost:27017"
2626
else
2727
echo "unsupported topology: $1"
2828
fi

0 commit comments

Comments
 (0)