for _, name in pairs(functionsToDecorate) do
model.accTime = {}
- local functionTable = model
-
- -- We decorate the function where it is defined in the class
- -- hierarchy, so we have to go up the metatables until we find
- -- it with rawget
-
- while functionTable and not rawget(functionTable, name) do
- functionTable = getmetatable(functionTable)
- end
-
local nameOrig = name .. '__orig'
- if functionTable[name] and not functionTable[nameOrig] then
- print('Profiler decoring ' .. functionTable.__typename .. '.' .. name)
- functionTable[nameOrig] = functionTable[name]
- functionTable[name] = function(self, ...)
+ if model[name] and not model[nameOrig] then
+ model[nameOrig] = model[name]
+ model[name] = function(self, ...)
local startTime = sys.clock()
local result = { self[nameOrig](self, unpack({...})) }
local endTime = sys.clock()