### profiler.print(model, [nbSamples], [totalTime]) ###
-Prints the measured processing times. If nbSamples is provided, the time per samples will also be printed. If totalTime is provided, the percentages will also be printed.
+Prints the measured processing times. If nbSamples is provided, the time per samples will also be printed. If totalTime is not provided, the total at the top is used.
Non-Containers are hilighted with a '*' or in red.
end
function profiler.timing(l, t, nbSamples, totalTime)
- local s = string.format('%s %.02fs', l, t)
- if totalTime then
- s = s .. string.format(profiler.colors('blue') .. ' [%.02f%%]', 100 * t / totalTime)
- end
+ local s
+
+ s = string.format('%s %.02fs %s[%.02f%%]',
+ l, t,
+ profiler.colors('blue'),
+ 100 * t / totalTime
+ )
+
if nbSamples then
s = s .. string.format(profiler.colors('green') .. ' (%.01fmus/sample)', 1e6 * t / nbSamples)
end
+
s = s .. profiler.colors('black')
+
return s
end
localTotal = localTotal + t
end
+ totalTime = totalTime or localTotal
+
if torch.isTypeOf(model, nn.Container) then
hint = ' '
else
hint = hint .. profiler.colors('red')
end
- print(profiler.timing(indent .. hint .. ' ' .. model.__typename, localTotal, nbSamples, totalTime))
+ print(profiler.timing(indent .. hint .. ' ' .. model.__typename,
+ localTotal, nbSamples, totalTime))
for l, t in pairs(model.accTime) do
- print(profiler.timing(indent .. ' ' .. l, t, nbSamples, totalTime))
+ print(profiler.timing(indent .. ' :' .. l, t, nbSamples, totalTime))
end
print()
-- Print the accumulated timings
--- profiler.color = false
-profiler.print(model, nbSamples, modelTime)
--- profiler.print(model)
+-- profiler.print(model, nbSamples)
+profiler.print(model)
print(string.format('Total model time %.02fs', modelTime))
print(string.format('Total data time %.02fs', dataTime))