-function profiler.print(model)
- print('----------------------------------------------------------------------')
- print(model)
- print(string.format('TIMING %.02fs', model.timings))
+function profiler.timingString(l, t, nbSamples, totalTime)
+ local s
+
+ s = string.format('%s %.02fs %s[%.02f%%]',
+ l, t,
+ profiler.colors('blue'),
+ 100 * t / totalTime
+ )
+
+ if nbSamples then
+ s = s .. string.format(profiler.colors('green') .. ' (%.01fmus/sample)',
+ 1e6 * t / nbSamples)
+ end
+
+ s = s .. profiler.colors('black')
+
+ return s
+end
+
+function profiler.print(model, nbSamples, totalTime, indent)
+ local indent = indent or ''
+ local hint
+
+ if not model.accTime then
+ error('The model does not seem decorated for profiling.')
+ end
+
+ local localTotal = 0
+ for _, t in pairs(model.accTime) do
+ localTotal = localTotal + t
+ end
+
+ totalTime = totalTime or localTotal
+