From: Francois Fleuret Date: Sun, 4 Dec 2016 16:35:12 +0000 (+0100) Subject: Changed the timing display. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=e05c72d75cf6c53887834d3c314a8ba6db6b56b3;p=profiler-torch.git Changed the timing display. --- 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 diff --git a/test-profiler.lua b/test-profiler.lua index 2f1f0ec..d17f320 100755 --- a/test-profiler.lua +++ b/test-profiler.lua @@ -49,6 +49,7 @@ local model = nn.Sequential() -- Decor it for profiling profiler.decor(model) +print() -- Create the data and criterion @@ -87,6 +88,6 @@ end profiler.print(model, nbSamples) -print('----------------------------------------------------------------------') +print() print(string.format('Total model time %.02fs', modelTime)) print(string.format('Total data time %.02fs', dataTime))