X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=profiler-torch.git;a=blobdiff_plain;f=profiler.lua;h=ad280d245ac3ddf6d03e34d4616fe35e04f20c67;hp=b95d7507575da856f5f4919e825a05a82b2eafb6;hb=40c92fc3324ed00f30d0f01f6b6c4010b2a1e1fe;hpb=4ed0c97b543f69caac452b7775a5ca57d017637a diff --git a/profiler.lua b/profiler.lua index b95d750..ad280d2 100644 --- a/profiler.lua +++ b/profiler.lua @@ -76,21 +76,14 @@ function profiler.print(model, nbSamples, indent) print(string.format('%s* %s', indent, model.__typename)) - if nbSamples then - for l, t in pairs(model.accTime) do - print(string.format('%s %s %.02fs (%.01fmus/sample)', - indent, - l, - t, - 1e6 * t / nbSamples)) - end - else - for l, t in pairs(model.accTime) do - print(string.format('%s %s %.02fs', - indent, - l, - t)) + for l, t in pairs(model.accTime) do + local s + if nbSamples then + s = string.format(' (%.01fmus/sample)', 1e6 * t / nbSamples) + else + s = '' end + print(string.format('%s %s %.02fs%s', indent, l, t, s)) end if torch.isTypeOf(model, nn.Container) then