annotate libinterp/parse-tree/profiler.cc @ 30346:91c6288781ba

maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599) * __isprimelarge__.cc, bsxfun.cc, cellfun.cc, chol.cc, data.cc, error.h, event-manager.h, filter.cc, find.cc, gcd.cc, gl-render.h, gl2ps-print.cc, graphics.cc, graphics.in.h, hash.cc, help.cc, hex2num.cc, input.cc, inv.cc, load-path.cc, load-save.cc, ls-hdf5.cc, ls-hdf5.h, ls-mat5.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mxarray.h, oct-errno.in.cc, oct-map.cc, oct-stream.cc, oct-stream.h, pr-output.cc, psi.cc, qr.cc, rand.cc, regexp.cc, sparse-xdiv.h, stack-frame.cc, strfind.cc, strfns.cc, sylvester.cc, symbfact.cc, symrec.h, symscope.cc, typecast.cc, utils.cc, variables.h, xdiv.h, xpow.h, __init_fltk__.cc, __ode15__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, cdef-class.cc, cdef-class.h, cdef-manager.cc, cdef-method.cc, cdef-object.cc, cdef-object.h, cdef-package.h, cdef-utils.cc, ov-base-diag.cc, ov-base-int.cc, ov-base.h, ov-bool-mat.cc, ov-bool.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-colon.h, ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-java.cc, ov-lazy-idx.cc, ov-lazy-idx.h, ov-range.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov.cc, ov.h, octave.h, bp-table.cc, bp-table.h, lex.h, oct-lvalue.h, profiler.cc, profiler.h, pt-binop.h, pt-colon.cc, pt-eval.cc, pt-exp.h, pt-select.h: Shorten some long lines in libinterp to <= 80 characters.
author Rik <rik@octave.org>
date Wed, 24 Nov 2021 09:38:51 -0800
parents 7d6709900da7
children 83f9f8bda883
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 2012-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
28 #endif
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
29
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
30 #include "defun.h"
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
31 #include "event-manager.h"
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
32 #include "interpreter.h"
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
33 #include "oct-time.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
34 #include "ov-struct.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
35 #include "pager.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
36 #include "profiler.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
37
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
38 OCTAVE_NAMESPACE_BEGIN
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
39
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
40 profiler::stats::stats (void)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
41 : m_time (0.0), m_calls (0), m_recursive (false),
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
42 m_parents (), m_children ()
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
43 { }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
44
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
45 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
46 profiler::stats::function_set_value (const function_set& list)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
47 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
48 const octave_idx_type n = list.size ();
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
49
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
50 RowVector retval (n);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
51 octave_idx_type i = 0;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
52 for (const auto& nm : list)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
53 retval(i++) = nm;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
54
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
55 assert (i == n);
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
56
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
57 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
58 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
59
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
60 profiler::tree_node::tree_node (tree_node *p, octave_idx_type f)
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
61 : m_parent (p), m_fcn_id (f), m_children (), m_time (0.0), m_calls (0)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
62 { }
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22755
diff changeset
63
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
64 profiler::tree_node::~tree_node ()
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
65 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
66 for (auto& idx_tnode : m_children)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
67 delete idx_tnode.second;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
68 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
69
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
70 profiler::tree_node*
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
71 profiler::tree_node::enter (octave_idx_type fcn)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
72 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
73 tree_node *retval;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
74
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75 child_map::iterator pos = m_children.find (fcn);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
76 if (pos == m_children.end ())
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
77 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
78 retval = new tree_node (this, fcn);
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79 m_children[fcn] = retval;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
80 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
81 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
82 retval = pos->second;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
83
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 ++retval->m_calls;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
85 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
86 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
87
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
88 profiler::tree_node*
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
89 profiler::tree_node::exit (octave_idx_type /* fcn */)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
90 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
91 // FIXME: These assert statements don't make sense if profile() is called
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
92 // from within a function hierarchy to begin with. See bug #39587.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
93 // assert (m_parent);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 // assert (m_fcn_id == fcn);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
95
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 return m_parent;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
97 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
98
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
99 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
100 profiler::tree_node::build_flat (flat_profile& data) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
101 {
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
102 // If this is not the top-level node,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
103 // update profile entry for this function.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104 if (m_fcn_id != 0)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
105 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
106 stats& entry = data[m_fcn_id - 1];
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
107
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
108 entry.m_time += m_time;
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
109 entry.m_calls += m_calls;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
110
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
111 assert (m_parent);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
112 if (m_parent->m_fcn_id != 0)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
113 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
114 entry.m_parents.insert (m_parent->m_fcn_id);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
115 data[m_parent->m_fcn_id - 1].m_children.insert (m_fcn_id);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
116 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
117
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
118 if (! entry.m_recursive)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
119 for (const tree_node *i = m_parent; i; i = i->m_parent)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
120 if (i->m_fcn_id == m_fcn_id)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
121 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
122 entry.m_recursive = true;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
123 break;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
124 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
125 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
126
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
127 // Recurse on children.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
128 for (const auto& idx_tnode : m_children)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
129 idx_tnode.second->build_flat (data);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
130 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
131
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
132 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
133 profiler::tree_node::get_hierarchical (double *total) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
134 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
135 // Note that we don't generate the entry just for this node, but
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
136 // rather a struct-array with entries for all children. This way, the
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
137 // top-node (for which we don't want a real entry) generates already
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
138 // the final hierarchical profile data.
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
139
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
140 const octave_idx_type n = m_children.size ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
141
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
142 Cell rv_indices (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
143 Cell rv_times (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
144 Cell rv_totals (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
145 Cell rv_calls (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
146 Cell rv_children (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
147
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
148 octave_idx_type i = 0;
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
149 for (const auto& idx_tnode : m_children)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
150 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
151 const tree_node& entry = *idx_tnode.second;
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
152 double child_total = entry.m_time;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
153
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
154 rv_indices(i) = octave_value (idx_tnode.first);
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
155 rv_times(i) = octave_value (entry.m_time);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
156 rv_calls(i) = octave_value (entry.m_calls);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
157 rv_children(i) = entry.get_hierarchical (&child_total);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
158 rv_totals(i) = octave_value (child_total);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
159
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
160 if (total)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
161 *total += child_total;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
162
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
163 ++i;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
164 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
165 assert (i == n);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
166
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
167 octave_map retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
168
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
169 retval.assign ("Index", rv_indices);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
170 retval.assign ("SelfTime", rv_times);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
171 retval.assign ("TotalTime", rv_totals);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
172 retval.assign ("NumCalls", rv_calls);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
173 retval.assign ("Children", rv_children);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
174
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
175 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
176 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
177
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
178 profiler::profiler (void)
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
179 : m_known_functions (), m_fcn_index (),
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
180 m_enabled (false), m_call_tree (new tree_node (nullptr, 0)),
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
181 m_active_fcn (nullptr), m_last_time (-1.0)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
182 { }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
183
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
184 profiler::~profiler (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
185 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
186 delete m_call_tree;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
187 }
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13052
diff changeset
188
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
189 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
190 profiler::set_active (bool value)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
191 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
192 m_enabled = value;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
193 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
194
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
195 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
196 profiler::enter_function (const std::string& fcn)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
197 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
198 // The enter class will check and only call us if the profiler is active.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
199 assert (enabled ());
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
200 assert (m_call_tree);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
201
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
202 // If there is already an active function, add to its time before
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
203 // pushing the new one.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
204 if (m_active_fcn && m_active_fcn != m_call_tree)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
205 add_current_time ();
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
206
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
207 // Map the function's name to its index.
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
208 octave_idx_type fcn_idx;
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
209 fcn_index_map::iterator pos = m_fcn_index.find (fcn);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
210 if (pos == m_fcn_index.end ())
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
211 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
212 m_known_functions.push_back (fcn);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
213 fcn_idx = m_known_functions.size ();
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
214 m_fcn_index[fcn] = fcn_idx;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
215 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
216 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
217 fcn_idx = pos->second;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
218
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
219 if (! m_active_fcn)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
220 m_active_fcn = m_call_tree;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
221
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
222 m_active_fcn = m_active_fcn->enter (fcn_idx);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
223
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
224 m_last_time = query_time ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
225
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
226 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
227
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
228 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
229 profiler::exit_function (const std::string& fcn)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
230 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
231 if (m_active_fcn)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
232 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
233 assert (m_call_tree);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
234 // FIXME: This assert statements doesn't make sense if profile() is
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
235 // called from within a function hierarchy to begin with. See bug
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
236 // #39587.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
237 //assert (m_active_fcn != m_call_tree);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
238
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
239 // Usually, if we are disabled this function is not even called. But
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
240 // the call disabling the profiler is an exception. So also check here
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
241 // and only record the time if enabled.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
242 if (enabled ())
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
243 add_current_time ();
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
244
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
245 fcn_index_map::iterator pos = m_fcn_index.find (fcn);
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
246 // FIXME: This assert statements doesn't make sense if profile() is
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
247 // called from within a function hierarchy to begin with. See bug
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
248 // #39587.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
249 //assert (pos != m_fcn_index.end ());
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
250 m_active_fcn = m_active_fcn->exit (pos->second);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
251
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
252 // If this was an "inner call", we resume executing the parent function
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
253 // up the stack. So note the start-time for this!
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
254 m_last_time = query_time ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
255 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
256 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
257
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
258 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
259 profiler::reset (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
260 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
261 if (enabled ())
28919
7bc983bc2cbd maint: Prepend name of function to error() messages.
Rik <rik@octave.org>
parents: 28905
diff changeset
262 error ("profile: can't reset active profiler");
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
263
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
264 m_known_functions.clear ();
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
265 m_fcn_index.clear ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
266
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 if (m_call_tree)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
268 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
269 delete m_call_tree;
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
270 m_call_tree = new tree_node (nullptr, 0);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 m_active_fcn = nullptr;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
272 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
273
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
274 m_last_time = -1.0;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
275 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
276
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
277 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
278 profiler::get_flat (void) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
279 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
280 octave_value retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
281
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
282 const octave_idx_type n = m_known_functions.size ();
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
283
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
284 flat_profile flat (n);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
285
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
286 if (m_call_tree)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
287 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
288 m_call_tree->build_flat (flat);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
289
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
290 Cell rv_names (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
291 Cell rv_times (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
292 Cell rv_calls (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
293 Cell rv_recursive (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
294 Cell rv_parents (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
295 Cell rv_children (n, 1);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
296
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
297 for (octave_idx_type i = 0; i != n; ++i)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
298 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
299 rv_names(i) = octave_value (m_known_functions[i]);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
300 rv_times(i) = octave_value (flat[i].m_time);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
301 rv_calls(i) = octave_value (flat[i].m_calls);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
302 rv_recursive(i) = octave_value (flat[i].m_recursive);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
303 rv_parents(i) = stats::function_set_value (flat[i].m_parents);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
304 rv_children(i) = stats::function_set_value (flat[i].m_children);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
305 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
306
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
307 octave_map m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
308
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
309 m.assign ("FunctionName", rv_names);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
310 m.assign ("TotalTime", rv_times);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
311 m.assign ("NumCalls", rv_calls);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
312 m.assign ("IsRecursive", rv_recursive);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
313 m.assign ("Parents", rv_parents);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
314 m.assign ("Children", rv_children);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
315
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
316 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
317 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
318 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
319 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
320 static const char *fn[] =
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
321 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
322 "FunctionName",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
323 "TotalTime",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
324 "NumCalls",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
325 "IsRecursive",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
326 "Parents",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
327 "Children",
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23753
diff changeset
328 nullptr
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
329 };
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
330
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
331 static octave_map m (dim_vector (0, 1), string_vector (fn));
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
332
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
333 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
334 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
335
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
336 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
337 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
338
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
339 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
340 profiler::get_hierarchical (void) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
341 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
342 octave_value retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
343
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
344 if (m_call_tree)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
345 retval = m_call_tree->get_hierarchical ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
346 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
347 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
348 static const char *fn[] =
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
349 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
350 "Index",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
351 "SelfTime",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
352 "NumCalls",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
353 "Children",
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23753
diff changeset
354 nullptr
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
355 };
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
356
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
357 static octave_map m (dim_vector (0, 1), string_vector (fn));
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
358
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
359 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
360 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
361
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
362 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
363 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
364
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
365 double
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
366 profiler::query_time (void) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
367 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
368 sys::time now;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
369
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
370 // FIXME: is this volatile declaration really needed?
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
371 // See bug #34210 for additional details.
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
372 volatile double dnow = now.double_value ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
373
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
374 return dnow;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
375 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
376
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
377 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
378 profiler::add_current_time (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
379 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
380 if (m_active_fcn)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
381 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
382 const double t = query_time ();
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
383
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
384 m_active_fcn->add_time (t - m_last_time);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
385 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
386 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
387
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
388 // Enable or disable the profiler data collection.
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
389 DEFMETHOD (__profiler_enable__, interp, args, ,
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
390 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
391 @deftypefn {} {} __profiler_enable__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
392 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
393 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
394 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
395 int nargin = args.length ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
396
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
397 if (nargin > 1)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
398 print_usage ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
399
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
400 profiler& profiler = interp.get_profiler ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
401
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
402 if (nargin == 1)
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
403 {
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
404 profiler.set_active (args(0).bool_value ());
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
405
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
406 std::string status = "off";
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
407 if (args(0).bool_value ())
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
408 status = "on";
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
409
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
410 event_manager& evmgr = interp.get_event_manager ();
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
411 evmgr.gui_status_update ("profiler", status); // tell GUI
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
412 }
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
413
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
414 return ovl (profiler.enabled ());
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
415 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
416
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
417 // Clear all collected profiling data.
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
418 DEFMETHOD (__profiler_reset__, interp, args, ,
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
419 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
420 @deftypefn {} {} __profiler_reset__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
421 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
422 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
423 {
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
424 if (args.length () != 0)
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
425 print_usage ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
426
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
427 profiler& profiler = interp.get_profiler ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
428
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
429 profiler.reset ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
430
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20939
diff changeset
431 return ovl ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
432 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
433
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
434 // Query the timings collected by the profiler.
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
435 DEFMETHOD (__profiler_data__, interp, args, nargout,
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
436 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
437 @deftypefn {} {} __profiler_data__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
438 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21730
diff changeset
439 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
440 {
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
441 if (args.length () != 0)
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
442 print_usage ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
443
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
444 profiler& profiler = interp.get_profiler ();
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
445
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
446 if (nargout > 1)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20892
diff changeset
447 return ovl (profiler.get_flat (), profiler.get_hierarchical ());
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20892
diff changeset
448 else
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20892
diff changeset
449 return ovl (profiler.get_flat ());
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
450 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
451
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
452 OCTAVE_NAMESPACE_END