projects
/
profiler-torch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6b672dd
)
Decorating the model themselves (and not the class) makes more sense as it allows...
author
Francois Fleuret
<francois@fleuret.org>
Mon, 5 Dec 2016 10:33:09 +0000
(11:33 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Mon, 5 Dec 2016 10:33:09 +0000
(11:33 +0100)
profiler.lua
patch
|
blob
|
history
diff --git
a/profiler.lua
b/profiler.lua
index
6f63861
..
b95d750
100644
(file)
--- a/
profiler.lua
+++ b/
profiler.lua
@@
-48,22
+48,11
@@
function profiler.decor(model, functionsToDecorate)
for _, name in pairs(functionsToDecorate) do
model.accTime = {}
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'
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()
local startTime = sys.clock()
local result = { self[nameOrig](self, unpack({...})) }
local endTime = sys.clock()