Changed the timing display.
[profiler-torch.git] / profiler.lua
index 58100e7..5490651 100755 (executable)
@@ -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