X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=profiler-torch.git;a=blobdiff_plain;f=profiler.lua;h=549065145ff94f758f390a8a7e99719a5ecb260b;hp=58100e7ae3766fde5836cd8d18e525affc45c0f4;hb=e05c72d75cf6c53887834d3c314a8ba6db6b56b3;hpb=1cc41a13ae500ceaf037b3ff880a0eeb25472633 diff --git a/profiler.lua b/profiler.lua index 58100e7..5490651 100755 --- a/profiler.lua +++ b/profiler.lua @@ -77,20 +77,25 @@ function profiler.decor(model, functionsToDecorate) end -function profiler.print(model, nbSamples) - print('----------------------------------------------------------------------') - print(model) +function profiler.print(model, nbSamples, indent) + local indent = indent or '' + if nbSamples then - print(string.format('acc_time %.02fs (%.01fmus/sample)', + print(string.format('%s%s %.02fs (%.01fmus/sample)', + indent, + model.__typename, model.accTime, 1e6 * model.accTime / nbSamples)) else - print(string.format('acc_time %.02fs', model.accTime)) + print(string.format('%s%s %.02fs', + indent, + model.__typename, + model.accTime)) end if torch.isTypeOf(model, nn.Container) then for _, m in ipairs(model.modules) do - profiler.print(m, nbSamples) + profiler.print(m, nbSamples, indent .. ' ') end end end