Difference between revisions of "Core.profilerStart"
From GiderosMobile
| m (Text replacement - "</source>" to "</syntaxhighlight>") | |||
| (One intermediate revision by the same user not shown) | |||
| Line 4: | Line 4: | ||
| === Description === | === Description === | ||
| Start recording of time spent in each lua function. | Start recording of time spent in each lua function. | ||
| − | < | + | <syntaxhighlight lang="lua"> | 
| Core.profilerStart() | Core.profilerStart() | ||
| − | </ | + | </syntaxhighlight> | 
| === Example === | === Example === | ||
| − | < | + | <syntaxhighlight lang="lua"> | 
| max = 10000 | max = 10000 | ||
| calls = 10 | calls = 10 | ||
| Line 54: | Line 54: | ||
| 	end | 	end | ||
| end | end | ||
| − | </ | + | </syntaxhighlight> | 
| {{Core}} | {{Core}} | ||
Latest revision as of 14:27, 13 July 2023
Available since: Gideros 2017.8
Class: Core
Description
Start recording of time spent in each lua function.
Core.profilerStart()
Example
max = 10000
calls = 10
a = -458
local abs=math.abs
function test1()
	for loop=1,max do
		local sign=math.abs(a)/a
	end
end
function test2()
	for loop=1,max do
		local sign=1
		if a<0 then sign=-1 end
	end
end
function test3()
	for loop=1,max do
		local sign=a < 0 and -1 or 1
	end
end
Core.profilerReset()
Core.profilerStart()
for loop = 1, calls do
	test1()
	test2()
	test3()
end
Core.profilerStop()
-- print the results of the profiler
result = Core.profilerReport()
print("Number of tests:", max*calls)
for k,v in pairs(result) do
	local found=false
	for k2,v2 in pairs(v) do
		if found and k2=="time" then print(v1,v2) end
		if k2=="name" and string.sub(v2,1,4)=="test" then v1=v2 found=true end
	end
end
- Core
- Core.asyncCall
- Core.asyncThread
- Core.class
- Core.enableAllocationTracking
- Core.fileLoad
- Core.fileSave
- Core.findReferences
- Core.frameStatistics
- Core.getScriptPath
- Core.profilerReport
- Core.profilerReset
- Core.profilerStart
- Core.profilerStop
- Core.random
- Core.randomSeed
- Core.setAutoYield
- Core.signal
- Core.stopping
- Core.yield
- Core.yieldable
- Core.yieldlock
