Mercurial > hg > octave-nkf
changeset 13188:6d57e53b21ea
Add field for total time to hierarchical profile.
profiler.h: Add new argument (for additional output) to get_hierarchical.
profiler.cc: Calculate total time when generating the hierarchical profile.
author | Daniel Kraft <d@domob.eu> |
---|---|
date | Thu, 22 Sep 2011 20:51:30 +0200 |
parents | 4e92b71dcc97 |
children | c5a8b23db680 |
files | src/profiler.cc src/profiler.h |
diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/profiler.cc +++ b/src/profiler.cc @@ -24,7 +24,6 @@ #include <config.h> #endif -#include <cstddef> #include <iostream> #include "defun.h" @@ -145,7 +144,7 @@ } octave_value -profile_data_accumulator::tree_node::get_hierarchical (void) const +profile_data_accumulator::tree_node::get_hierarchical (double* total) const { /* Note that we don't generate the entry just for this node, but rather a struct-array with entries for all children. This way, the top-node @@ -156,6 +155,7 @@ Cell rv_indices (n, 1); Cell rv_times (n, 1); + Cell rv_totals (n, 1); Cell rv_calls (n, 1); Cell rv_children (n, 1); @@ -164,11 +164,16 @@ p != children.end (); ++p) { const tree_node& entry = *p->second; + double child_total = entry.time; rv_indices(i) = octave_value (p->first); rv_times(i) = octave_value (entry.time); rv_calls(i) = octave_value (entry.calls); - rv_children(i) = entry.get_hierarchical (); + rv_children(i) = entry.get_hierarchical (&child_total); + rv_totals(i) = octave_value (child_total); + + if (total) + *total += child_total; ++i; } @@ -178,6 +183,7 @@ retval.assign ("Index", rv_indices); retval.assign ("SelfTime", rv_times); + retval.assign ("TotalTime", rv_totals); retval.assign ("NumCalls", rv_calls); retval.assign ("Children", rv_children);
--- a/src/profiler.h +++ b/src/profiler.h @@ -23,6 +23,7 @@ #if !defined (octave_profiler_h) #define octave_profiler_h 1 +#include <cstddef> #include <map> #include <set> #include <string> @@ -113,7 +114,11 @@ tree_node* exit (octave_idx_type); void build_flat (flat_profile&) const; - octave_value get_hierarchical (void) const; + + // Get the hierarchical profile for this node and its children. If total + // is set, accumulate total time of the subtree in that variable as + // additional return value. + octave_value get_hierarchical (double* total = NULL) const; private: