37 : time (0.0), calls (0), recursive (false),
38 parents (), children ()
48 for (function_set::const_iterator p = list.begin (); p != list.end (); ++p)
59 : parent (p), fcn_id (f), children (), time (0.0), calls (0)
64 for (child_map::iterator i = children.begin (); i != children.end (); ++i)
73 child_map::iterator pos = children.find (fcn);
74 if (pos == children.end ())
77 children[fcn] = retval;
103 stats& entry = data[fcn_id - 1];
106 entry.
calls += calls;
109 if (parent->fcn_id != 0)
111 entry.
parents.insert (parent->fcn_id);
112 data[parent->fcn_id - 1].children.insert (fcn_id);
117 if (i->fcn_id == fcn_id)
125 for (child_map::const_iterator i = children.begin ();
126 i != children.end (); ++i)
127 i->second->build_flat (data);
140 Cell rv_indices (n, 1);
141 Cell rv_times (n, 1);
142 Cell rv_totals (n, 1);
143 Cell rv_calls (n, 1);
144 Cell rv_children (n, 1);
147 for (child_map::const_iterator p = children.begin ();
148 p != children.end (); ++p)
151 double child_total = entry.
time;
160 *total += child_total;
168 retval.
assign (
"Index", rv_indices);
169 retval.
assign (
"SelfTime", rv_times);
170 retval.
assign (
"TotalTime", rv_totals);
171 retval.
assign (
"NumCalls", rv_calls);
172 retval.
assign (
"Children", rv_children);
224 fcn_index_map::iterator pos =
fcn_index.find (fcn);
232 fcn_idx = pos->second;
253 fcn_index_map::iterator pos =
fcn_index.find (fcn);
269 error (
"Can't reset active profiler.");
298 Cell rv_names (n, 1);
299 Cell rv_times (n, 1);
300 Cell rv_calls (n, 1);
301 Cell rv_recursive (n, 1);
302 Cell rv_parents (n, 1);
303 Cell rv_children (n, 1);
317 m.
assign (
"FunctionName", rv_names);
318 m.
assign (
"TotalTime", rv_times);
319 m.
assign (
"NumCalls", rv_calls);
320 m.
assign (
"IsRecursive", rv_recursive);
321 m.
assign (
"Parents", rv_parents);
322 m.
assign (
"Children", rv_children);
328 static const char *fn[] =
356 static const char *fn[] =
398 DEFUN (__profiler_enable__, args, ,
400 @deftypefn {Function File} {} __profiler_enable__ ()\n\
401 Undocumented internal function.\n\
406 const int nargin = args.
length ();
424 DEFUN (__profiler_reset__, args, ,
426 @deftypefn {Function File} {} __profiler_reset__ ()\n\
427 Undocumented internal function.\n\
431 const int nargin = args.
length ();
434 warning (
"profiler_reset: ignoring extra arguments");
442 DEFUN (__profiler_data__, args, nargout,
444 @deftypefn {Function File} {} __profiler_data__ ()\n\
445 Undocumented internal function.\n\
449 const int nargin = args.
length ();
452 warning (
"profiler_data: ignoring extra arguments");
void assign(const std::string &k, const Cell &val)
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
function_set known_functions
octave_value get_hierarchical(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
tree_node * enter(octave_idx_type)
tree_node(tree_node *, octave_idx_type)
double double_value(void) const
tree_node * exit(octave_idx_type)
void add_current_time(void)
void build_flat(flat_profile &) const
bool is_active(void) const
F77_RET_T const double const double * f
std::vector< stats > flat_profile
octave_value get_flat(void) const
void exit_function(const std::string &)
std::set< octave_idx_type > function_set
profile_data_accumulator(void)
double query_time() const
void warning(const char *fmt,...)
virtual ~profile_data_accumulator()
static octave_value function_set_value(const function_set &)
bool bool_value(bool warn=false) const
void enter_function(const std::string &)
octave_value get_hierarchical(double *total=0) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
profile_data_accumulator profiler