Changed the timing display.
authorFrancois Fleuret <francois@fleuret.org>
Sun, 4 Dec 2016 16:35:12 +0000 (17:35 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Sun, 4 Dec 2016 16:35:12 +0000 (17:35 +0100)
profiler.lua
test-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
index 2f1f0ec..d17f320 100755 (executable)
@@ -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))