不要怂,就是干,撸起袖子干!

Commit d238a052 by Mick Hansen Committed by Jan Aagaard Meier

metric logging for performance benchmarking

1 parent decde794
Showing with 13 additions and 1 deletions
......@@ -171,10 +171,12 @@ module.exports = (function() {
return this.QueryInterface.rawSelect(this.tableName, options, 'min')
}
var tk = require('timekit');
DAOFactory.prototype.build = function(values, options) {
var start = tk.time();
var instance = new DAO(values, Utils._.extend(this.options, this.attributes, { hasPrimaryKeys: this.hasPrimaryKeys }))
, self = this
this.daoFactoryManager.sequelize._metric('Model.build -> new DAO', tk.time() - start);
options = options || {}
instance.__factory = this
......
......@@ -88,6 +88,16 @@ module.exports = (function() {
return this.migrator
}
Sequelize.prototype._metric = function(label, time, reset) {
if (reset === undefined) reset = false;
if (!this._metrics) this._metrics = {};
if (!time && this._metrics[label]) return this._metrics[label];
if (!time && label) return label+' wasn\'t logged';
if (!time && !label) return this._metrics;
if (!this._metrics[label] || reset) this._metrics[label] = [];
this._metrics[label].push(time);
}
Sequelize.prototype.define = function(daoName, attributes, options) {
options = options || {}
if(this.options.define) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!