
.namespace Profiler

function OnEnable()
	DataProfile = {}
end 

function StartFunction(name)
	if DataProfile[name]== nil then
		DataProfile[name]={}
		DataProfile[name].cumultime = 0
	end
	DataProfile[name].starttime = OPTime.GetTime()
end

function EndFunction(name)
	DataProfile[name].cumultime = DataProfile[name].cumultime + OPTime.GetTime() - DataProfile[name].starttime
end

function DisplayProfiling()
	g_display = OPUnitFactory.CreateUnit("GUIText")
	g_display.Font=Load("Font","GUIFont")
	g_display.LineSpacing = -20
end

function OnUpdate()
	if g_display ~= nil then
		g_display.Text = GlobalFunctions.Display(DataProfile)
	end
end	