26#if defined (HAVE_CONFIG_H)
41 : m_time (0.0), m_calls (0), m_recursive (false),
42 m_parents (), m_children ()
52 for (
const auto& nm : list)
61 : m_parent (p), m_fcn_id (
f), m_children (), m_time (0.0), m_calls (0)
66 for (
auto& idx_tnode : m_children)
67 delete idx_tnode.second;
75 child_map::iterator pos = m_children.find (fcn);
76 if (pos == m_children.end ())
79 m_children[fcn] = retval;
105 stats& entry = data[m_fcn_id - 1];
111 if (m_parent->m_fcn_id != 0)
113 entry.
m_parents.insert (m_parent->m_fcn_id);
114 data[m_parent->m_fcn_id - 1].m_children.insert (m_fcn_id);
119 if (i->m_fcn_id == m_fcn_id)
127 for (
const auto& idx_tnode : m_children)
128 idx_tnode.second->build_flat (data);
141 Cell rv_indices (n, 1);
142 Cell rv_times (n, 1);
143 Cell rv_totals (n, 1);
144 Cell rv_calls (n, 1);
145 Cell rv_children (n, 1);
148 for (
const auto& idx_tnode : m_children)
150 const tree_node& entry = *idx_tnode.second;
151 double child_total = entry.
m_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);
208 fcn_index_map::iterator pos =
m_fcn_index.find (fcn);
216 fcn_idx = pos->second;
243 fcn_index_map::iterator pos =
m_fcn_index.find (fcn);
259 error (
"profile: can't reset active profiler");
287 Cell rv_names (n, 1);
288 Cell rv_times (n, 1);
289 Cell rv_calls (n, 1);
290 Cell rv_recursive (n, 1);
291 Cell rv_parents (n, 1);
292 Cell rv_children (n, 1);
306 m.
assign (
"FunctionName", rv_names);
307 m.
assign (
"TotalTime", rv_times);
308 m.
assign (
"NumCalls", rv_calls);
309 m.
assign (
"IsRecursive", rv_recursive);
310 m.
assign (
"Parents", rv_parents);
311 m.
assign (
"Children", rv_children);
317 static const char *fn[] =
345 static const char *fn[] =
369 volatile double dnow = now.double_value ();
386DEFMETHOD (__profiler_enable__, interp, args, ,
392 int nargin = args.length ();
403 std::string status =
"off";
404 if (args(0).bool_value ())
415DEFMETHOD (__profiler_reset__, interp, args, ,
421 if (args.length () != 0)
432DEFMETHOD (__profiler_data__, interp, args, nargout,
438 if (args.length () != 0)
Vector representing the dimensions (size) of an Array.
Provides threadsafe access to octave.
bool gui_status_update(const std::string &feature, const std::string &status)
void assign(const std::string &k, const Cell &val)
void build_flat(flat_profile &) const
octave_value get_hierarchical(double *total=nullptr) const
tree_node * exit(octave_idx_type)
tree_node(tree_node *, octave_idx_type)
tree_node * enter(octave_idx_type)
octave_value get_flat(void) const
fcn_index_map m_fcn_index
double query_time(void) const
void add_current_time(void)
std::vector< stats > flat_profile
octave_value get_hierarchical(void) const
void exit_function(const std::string &)
function_set m_known_functions
void enter_function(const std::string &)
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
void error(const char *fmt,...)
F77_RET_T const F77_DBLE const F77_DBLE * f
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
static octave_value function_set_value(const function_set &)
std::set< octave_idx_type > function_set