{"size": 922, "ext": "js", "max_stars_repo_path": "demo/profiler.js", "max_stars_repo_name": "Demokerho/cerho", "max_stars_repo_stars_event_min_datetime": "2015-01-19T20:27:51.000Z", "max_stars_repo_stars_event_max_datetime": "2015-01-19T20:27:51.000Z", "max_issues_repo_path": "demo/profiler.js", "max_issues_repo_name": "Demokerho/cerho", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "demo/profiler.js", "max_forks_repo_name": "Demokerho/cerho", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.2083333333, "max_line_length": 93, "alphanum_fraction": 0.6464208243}
/* 
 * A simple profiler module.
 *
 * Usage example:
 *
 * 		Profiler.begin("render");
 * 		renderScene();
 * 		Profiler.end("render");
 * 		console.log(Profiler.getTimes());
 *
 */

var Profiler = (function (utils) {
	// http://dvolvr.davidwaterston.com/2012/06/24/javascript-accurate-timing-is-almost-here/


	function Profiler() {
		this.entries = [];
	}

	Profiler.prototype.begin = function (eventName) {
		this.entries[eventName] = {
			begin: utils.getNow(),
			end: -1
		};
	}

	Profiler.prototype.end = function (eventName) {
		this.entries[eventName].end = utils.getNow();
		this.entries[eventName].diff = this.entries[eventName].end - this.entries[eventName].begin;
	}

	Profiler.prototype.getTimes = function () {
		var list = [];

		for (var key in this.entries) {
			if (this.entries.hasOwnProperty(key)) {
				list[key] =  this.entries[key].diff;
			}
		}


		return list;
	}

	return Profiler;
})(Utils);
