Permalink
Browse files

more bench stubs for profiling

  • Loading branch information...
1 parent 4e041ab commit d9939512f2164156ab9d786afbb8ce65fe7cef29 @aheckmann aheckmann committed Dec 12, 2011
Showing with 60 additions and 10 deletions.
  1. +60 −0 benchmarks/clone.js
  2. +0 −10 benchmarks/mem.js
View
@@ -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
View
@@ -85,17 +85,7 @@ methods.push(function (a, cb) {
cb();
});
-
-// bench the normal way
-// the try building the doc into the document prototype
-// and using inheritance and bench that
-//
-// also, bench using listeners for each subdoc vs one
-// listener that knows about all subdocs and notifies
-// them.
-
var started = process.memoryUsage();
-//console.error(started);
var start = new Date;
var total = 500;
var i = total;

0 comments on commit d993951

Please sign in to comment.