// Profile.js: simple time profiling

profile = {
	_enabled: true,
	_startTime: Date.now(),
	_previousTime: Date.now(),

	reset: function () {
		this._startTime = Date.now();
		this._previousTime = Date.now();
	},

	checkPoint: function (label, methodName) {
		if (!this._enabled)
			return;

		var now = Date.now();
		console.log("profile: "
			+ label
			+ ": since last: "
			+ ((now - this._previousTime) / 1000)
			+ "s, since start: "
			+ ((now - this._startTime) / 1000)
			+ "s   (method: "
			+ methodName + ")"
			);

		this._previousTime = now;
	}
};
