Method code for $code_lib._trace_profile()

[Turn off line numbering]
  1: arg list;
  2: var i, out, ref, times, sums, callers, t, tic, max, start;
  3: 
  4: out = ["Object<definer>.method                               Tics  (%)  Cummul. (%)"];
  5: times = #[];
  6: sums = #[];
  7: callers = [];
  8: for i in (list) {
  9:     refresh();
 10:     if (type(i) == 'integer) {
 11:         if (callers) {
 12:             [[ref, tic], @callers] = callers;
 13:             times = times.add(ref, ((| times[ref] |) || 0) + i[1] - t);
 14:             sums = sums.add(ref, ((| sums[ref] |) || 0) + i[1] - tic);
 15:         }
 16:         t = i;
 17:     } else {
 18:         if (callers) {
 19:             ref = callers[1][1];
 20:             times = times.add(ref, ((| sums[ref] |) || 0) + i[1] - t);
 21:         }
 22:         ref = strfmt("%l<%l>.%l", i[2], i[3], i[4]);
 23:         callers = [[ref, i[1]], @callers];
 24:         t = i[1];
 25:     }
 26:     start ?= t;
 27: }
 28: max = 0.01 * (t - start);
 29: out = map i in (times.keys()) to (refresh() && [i, times[i], times[i] / max, sums[i], sums[i] / max]);
 30: out = out.sort(out.slice(2));
 31: out = map i in (out) to (strfmt(i, "%50l%7r%7r%7r%7r"));
 32: return out;

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon