summaryrefslogtreecommitdiff
path: root/node_modules/mongoose/benchmarks/clone.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
committerJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
commit686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch)
treea5b5e50237cef70e12f0745371896e96f5f6d578 /node_modules/mongoose/benchmarks/clone.js
ok
Diffstat (limited to 'node_modules/mongoose/benchmarks/clone.js')
-rw-r--r--node_modules/mongoose/benchmarks/clone.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/node_modules/mongoose/benchmarks/clone.js b/node_modules/mongoose/benchmarks/clone.js
new file mode 100644
index 0000000..45aa6a7
--- /dev/null
+++ b/node_modules/mongoose/benchmarks/clone.js
@@ -0,0 +1,60 @@
+
+var mongoose = require('../')
+ , utils = require('../lib/utils')
+ , clone = utils.clone
+ , Schema = mongoose.Schema
+
+var DocSchema = new Schema({
+ title: String
+});
+
+var AllSchema = new Schema({
+ string: { type: String, required: true }
+ , number: { type: Number, min: 10 }
+ , date : Date
+ , bool : Boolean
+ , buffer: Buffer
+ , objectid: Schema.ObjectId
+ , array : Array
+ , strings: [String]
+ , numbers: [Number]
+ , dates : [Date]
+ , bools : [Boolean]
+ , buffers: [Buffer]
+ , objectids: [Schema.ObjectId]
+ , docs : { type: [DocSchema], validate: function () { return true }}
+ , s: { nest: String }
+});
+
+var A = mongoose.model('A', AllSchema);
+var a = new A({
+ string: "hello world"
+ , number: 444848484
+ , date: new Date
+ , bool: true
+ , buffer: new Buffer(0)
+ , objectid: new mongoose.Types.ObjectId()
+ , array: [4,{},[],"asdfa"]
+ , strings: ["one","two","three","four"]
+ , numbers:[72,6493,83984643,348282.55]
+ , dates:[new Date, new Date, new Date]
+ , bools:[true, false, false, true, true]
+ , buffers: [new Buffer([33]), new Buffer([12])]
+ , objectids: [new mongoose.Types.ObjectId]
+ , docs: [ {title: "yo"}, {title:"nowafasdi0fas asjkdfla fa" }]
+ , s: { nest: 'hello there everyone!' }
+});
+
+var start = new Date;
+var total = 100000;
+var i = total;
+
+for (var i = 0, len = total; i < len; ++i) {
+ a.toObject({ depopulate: true });
+}
+
+var time= (new Date - start)/1000;
+console.error('took %d seconds for %d docs (%d dps)', time, total, total/time);
+var used = process.memoryUsage();
+
+// --trace-opt --trace-deopt --trace-bailout