exporting patch:
# HG changeset patch
# User Daniel Kraft
# Date 1316717490 -7200
# Node ID 6d57e53b21ea7145b0754cdf0088f4ad558b4fed
# Parent 4e92b71dcc97f1bea62f45986d42fecf9a144c1f
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.
diff -r 4e92b71dcc97 -r 6d57e53b21ea src/profiler.cc
--- a/src/profiler.cc Mon Sep 19 09:37:52 2011 -0700
+++ b/src/profiler.cc Thu Sep 22 20:51:30 2011 +0200
@@ -24,7 +24,6 @@
#include
#endif
-#include
#include
#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);
diff -r 4e92b71dcc97 -r 6d57e53b21ea src/profiler.h
--- a/src/profiler.h Mon Sep 19 09:37:52 2011 -0700
+++ b/src/profiler.h Thu Sep 22 20:51:30 2011 +0200
@@ -23,6 +23,7 @@
#if !defined (octave_profiler_h)
#define octave_profiler_h 1
+#include
#include