-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
537 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const mongoose = require('../'); | ||
|
||
run().catch(err => { | ||
console.error(err); | ||
process.exit(-1); | ||
}); | ||
|
||
async function run() { | ||
await mongoose.connect('mongodb://127.0.0.1:27017/mongoose_benchmark'); | ||
|
||
const levels = 12; | ||
|
||
let schema = new mongoose.Schema({ test: { type: String, required: true } }); | ||
let doc = { test: 'gh-14897' }; | ||
for (let i = 0; i < levels; ++i) { | ||
schema = new mongoose.Schema({ level: Number, subdocs: [schema] }); | ||
doc = { level: (levels - i), subdocs: [{ ...doc }, { ...doc }] }; | ||
} | ||
const Test = mongoose.model('Test', schema); | ||
|
||
if (!process.env.MONGOOSE_BENCHMARK_SKIP_SETUP) { | ||
await Test.deleteMany({}); | ||
} | ||
|
||
const insertStart = Date.now(); | ||
await Test.create(doc); | ||
const insertEnd = Date.now(); | ||
|
||
const results = { | ||
'create() time ms': +(insertEnd - insertStart).toFixed(2) | ||
}; | ||
|
||
console.log(JSON.stringify(results, null, ' ')); | ||
process.exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.