! fixed pepper fish to work with lua 5.3.4
This commit is contained in:
parent
1abac192cb
commit
541958e4d2
@ -206,8 +206,9 @@ function _profiler._internal_profile_by_call(self,action)
|
||||
|
||||
-- Retrieve the most recent activation record...
|
||||
local latest_ar = nil
|
||||
if table.getn(self.callstack) > 0 then
|
||||
latest_ar = self.callstack[table.getn(self.callstack)]
|
||||
local callstackLen = #self.callstack
|
||||
if callstackLen > 0 then
|
||||
latest_ar = self.callstack[callstackLen]
|
||||
end
|
||||
|
||||
-- Are we allowed to profile this function?
|
||||
@ -280,7 +281,8 @@ function _profiler._internal_profile_by_call(self,action)
|
||||
end
|
||||
|
||||
-- Last thing to do on return is to drop the last activation record...
|
||||
table.remove( self.callstack, table.getn( self.callstack ) )
|
||||
local callstackLen = #self.callstack
|
||||
table.remove( self.callstack, callstackLen )
|
||||
end
|
||||
end
|
||||
|
||||
@ -400,13 +402,15 @@ function _profiler.report( self, outfile, sort_by_total_time )
|
||||
)
|
||||
end
|
||||
|
||||
for i=1,table.getn(ordering) do
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local func = ordering[i]
|
||||
local record = self.rawstats[func]
|
||||
local thisfuncname = " " .. self:_pretty_name(func) .. " "
|
||||
if string.len( thisfuncname ) < 42 then
|
||||
local nameLen = math.ceil((42 - string.len(thisfuncname))/2)
|
||||
thisfuncname =
|
||||
string.rep( "-", (42 - string.len(thisfuncname))/2 ) .. thisfuncname
|
||||
string.rep( "-", nameLen) .. thisfuncname
|
||||
thisfuncname =
|
||||
thisfuncname .. string.rep( "-", 42 - string.len(thisfuncname) )
|
||||
end
|
||||
@ -476,20 +480,24 @@ function _profiler.lua_report(self,outfile)
|
||||
local functonum = {}
|
||||
for func,record in pairs(self.rawstats) do
|
||||
table.insert(ordering, func)
|
||||
functonum[func] = table.getn(ordering)
|
||||
local len = #ordering
|
||||
functonum[func] = len
|
||||
end
|
||||
|
||||
outfile:write(
|
||||
"-- Profile generated by profiler.lua Copyright Pepperfish 2002+\n\n" )
|
||||
outfile:write( "-- Function names\nfuncnames = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local thisfunc = ordering[i]
|
||||
outfile:write( "funcnames[" .. i .. "] = " ..
|
||||
string.format("%q", self:_pretty_name(thisfunc)) .. "\n" )
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Function times\nfunctimes = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "functimes[" .. i .. "] = { " )
|
||||
@ -500,7 +508,9 @@ function _profiler.lua_report(self,outfile)
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child links\nchildren = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
@ -513,7 +523,9 @@ function _profiler.lua_report(self,outfile)
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child call counts\nchildcounts = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc]
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
@ -526,7 +538,8 @@ function _profiler.lua_report(self,outfile)
|
||||
end
|
||||
outfile:write( "\n" )
|
||||
outfile:write( "-- Child call time\nchildtimes = {}\n" )
|
||||
for i=1,table.getn(ordering) do
|
||||
local len = #ordering
|
||||
for i=1,len do
|
||||
local thisfunc = ordering[i]
|
||||
local record = self.rawstats[thisfunc];
|
||||
outfile:write( "children[" .. i .. "] = { " )
|
||||
|
Loading…
Reference in New Issue
Block a user