package com.indindi.Raster
{
	import flash.display.MovieClip;	
	
	import com.indindi.Raster.FrameRate;

	public class TimePerf extends MovieClip
	{
		private var _perfsObj:Object;
		private var _nbPerfs:int;
		
		
		public function TimePerf():void
		{
			_perfsObj = new Object();
			_nbPerfs = 0;
		}
		
		// Ajoute un type de perf : int compris entre 0 et 1
		public function AddPerfType(perfNom:String, perfVal:Number = 0.0) {
			_perfsObj[perfNom] = perfVal;
			_perfsObj.setPropertyIsEnumerable(perfNom, true);
			_nbPerfs++;
		}
				
		// Reinit toutes les perfs
		public function ReinitPerfs():void
		{
			// Fini de compter... on recommence
			for (var a_perf_nom:String in _perfsObj) {
				_perfsObj[a_perf_nom] = 0.0;
			}
		}
		
		// Afficher perfs
		public function TracePerfs():void
		{
			for (var a_perf_nom:String in _perfsObj) {
				trace("Perf Nom = "+a_perf_nom+" | Perf Val = "+_perfsObj[a_perf_nom]);
			}
		}
		
		public function UpdatePerfByType(perfNom:String, perfVal:Number):void
		{
			_perfsObj[perfNom] += perfVal;
		}
		
		public function PerformPerfs(totalDiffTime:Number)
		{
			for (var a_perf_nom:String in _perfsObj) {
				//trace("diff = "+_perfsObj[a_perf_nom]);
				if(totalDiffTime != 0) {
					_perfsObj[a_perf_nom] /= totalDiffTime;
				}
			}
		}
		
		public function GetPerfs():Object
		{
			return _perfsObj;
		}
		
		public function GetNbPerfs():int
		{
			return _nbPerfs;
		}
	}
	
}