changeset 12887:ca5c1115b679

Show recursive-flag of functions in profshow. * profshow.m: Add attribute column to display table, which shows the recursive flag of function data.
author Daniel Kraft <d@domob.eu>
date Mon, 25 Jul 2011 11:24:18 +0200
parents 29cd5a828bb2
children 40dc9069297a
files scripts/general/profshow.m
diffstat 1 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/profshow.m
+++ b/scripts/general/profshow.m
@@ -27,6 +27,9 @@
 ## sorted in descending order by total time spent in them.  If there are more
 ## than @var{n} included in the profile, those will not be shown.  @var{n}
 ## defaults to 20.
+##
+## The attribute column shows @samp{R} for recursive functions and nothing
+## otherwise.
 ## @end deftypefn
 
 ## Built-in profiler.
@@ -60,19 +63,22 @@
   for i = 1 : n
     nameLen = max (nameLen, length (data.FunctionTable(p(i)).FunctionName));
   endfor
-  headerFormat = sprintf ('%%%ds %%12s %%12s\n', nameLen);
-  rowFormat = sprintf ('%%%ds%%13.3f%%13d\n', nameLen);
+  headerFormat = sprintf ('%%%ds %%4s %%12s %%12s\n', nameLen);
+  rowFormat = sprintf ('%%%ds %%4s %%12.3f %%12d\n', nameLen);
 
-  printf (headerFormat, 'Function', 'Time (s)', 'Calls');
-  printf ("%s\n", repmat ('-', 1, nameLen + 2 * 13));
+  printf (headerFormat, 'Function', 'Attr', 'Time (s)', 'Calls');
+  printf ("%s\n", repmat ('-', 1, nameLen + 2 * 13 + 5));
   for i = 1 : n
     row = data.FunctionTable(p(i));
-    printf (rowFormat, row.FunctionName, row.TotalTime, row.NumCalls);
+    attr = '';
+    if (row.IsRecursive)
+      attr = 'R';
+    endif
+    printf (rowFormat, row.FunctionName, attr, row.TotalTime, row.NumCalls);
   endfor
 
 endfunction
 
-
 %!demo
 %! profile ('on');
 %! A = rand (100);
@@ -80,3 +86,16 @@
 %! profile ('off');
 %! T = profile ('info');
 %! profshow (T, 10);
+
+%!demo
+%! function f = myfib (n)
+%!   if (n <= 2)
+%!     f = 1;
+%!   else
+%!     f = myfib (n - 1) + myfib (n - 2);
+%!   endif
+%! endfunction
+%! profile ('on');
+%! myfib (20);
+%! profile ('off');
+%! profshow (profile ('info'), 5);