// függőségek
if ("undefined" == typeof AITIA) {
	alert("AITIA include missing!");
} else if ("undefined" == typeof AITIA_UTIL) {
	alert("AITIA_UTIL include missing!");
}

// többszörös include
if ("undefined" != typeof AITIA_BENCHMARK) {
	// alert("AITIA_BENCHMARK multiple insert!");
}

AITIA_BENCHMARK = 1;

// konstruktor
Aitia.Benchmark = function() {
	
}

Aitia.Benchmark.prototype.init = function(config) {
	this.size = null;
  this.times = null;
  this.prevTime = null;
	
	
	this.setDefaults();
	this.readConfig(config);

		
	this.reset();
} // init

Aitia.Benchmark.prototype.setDefaults = function() {
	this.size = 5;
} // setDefaults

Aitia.Benchmark.prototype.readConfig = function(cfg) {
	
} // readConfig

Aitia.Benchmark.prototype.check = function(str) {
  var now = new Date().getTime();
  this.times[this.times.length] = {msg: str, time: now - this.prevTime};
  this.prevTime = now;
} // check

Aitia.Benchmark.prototype.reset = function() {
  this.times = new Array();
  this.prevTime = new Date().getTime();
  this.check('start test');
} // reset

Aitia.Benchmark.prototype.show = function() {
	
  Aitia.Util.sort(this.times,Aitia.Benchmark.cmpFunc);
  
  var txt = '';
  for (var i = 0 ; i < this.size && i < this.times.length ; ++i) {
    txt += this.times[i].msg+': '+this.times[i].time+' ms\n';
  }

  this.reset();
    
  alert(txt);
} // show

Aitia.Benchmark.cmpFunc = function(a,b) {
	if (a.time < b.time) {
		return -1;
	} else if (a.time > b.time) {
		return 1;
	}	
	return 0;
} // cmpFunc

