annotate libinterp/parse-tree/profiler.cc @ 29961:7d6709900da7

eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more Files affected: __betainc__.cc, __contourc__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, balance.cc, besselj.cc, bsxfun.cc, call-stack.cc, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, defaults.cc, dirfns.cc, display.cc, dlmread.cc, dmperm.cc, dot.cc, eig.cc, ellipj.cc, environment.cc, error.cc, event-manager.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, find.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, gsvd.cc, hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jsondecode.cc, jsonencode.cc, load-path.cc, load-save.cc, lookup.cc, lsode.cc, lu.cc, max.cc, mgorth.cc, oct-hist.cc, ordqz.cc, ordschur.cc, pager.cc, pr-output.cc, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, regexp.cc, schur.cc, settings.cc, sighandlers.cc, sparse.cc, spparms.cc, sqrtm.cc, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, symbfact.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-struct.cc, ov-typeinfo.cc, ov-usr-fcn.cc, octave.cc, lex.ll, oct-parse.yy, profiler.cc, andpt-eval.cc.
author John W. Eaton <jwe@octave.org>
date Sat, 14 Aug 2021 22:48:52 -0400
parents 939bef0b66e0
children 91c6288781ba 796f54d4ddbf
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 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
102 // If this is not the top-level node, 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
103 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
104 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
105 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
106
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 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
108 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
109
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
110 assert (m_parent);
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
111 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
112 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
113 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
114 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
115 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
116
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
117 if (! entry.m_recursive)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
118 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
119 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
120 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
121 entry.m_recursive = true;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
122 break;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
123 }
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 // Recurse on children.
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
127 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
128 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
129 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
130
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
131 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
132 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
133 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
134 // 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
135 // 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
136 // 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
137 // the final hierarchical profile data.
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
138
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
139 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
140
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
141 Cell rv_indices (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
142 Cell rv_times (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
143 Cell rv_totals (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
144 Cell rv_calls (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
145 Cell rv_children (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
146
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
147 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
148 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
149 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
150 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
151 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
152
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
153 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
154 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
155 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
156 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
157 rv_totals(i) = octave_value (child_total);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
158
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
159 if (total)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
160 *total += child_total;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
161
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
162 ++i;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
163 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
164 assert (i == n);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
165
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
166 octave_map retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
167
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
168 retval.assign ("Index", rv_indices);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
169 retval.assign ("SelfTime", rv_times);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
170 retval.assign ("TotalTime", rv_totals);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
171 retval.assign ("NumCalls", rv_calls);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
172 retval.assign ("Children", rv_children);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
173
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
174 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
175 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
176
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
177 profiler::profiler (void)
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
178 : 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
179 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
180 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
181 { }
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 profiler::~profiler (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
184 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
185 delete m_call_tree;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
186 }
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13052
diff changeset
187
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
188 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
189 profiler::set_active (bool value)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
190 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
191 m_enabled = value;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
192 }
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 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
195 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
196 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
197 // 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
198 assert (enabled ());
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
199 assert (m_call_tree);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
200
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
201 // 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
202 // 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
203 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
204 add_current_time ();
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
205
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
206 // 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
207 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
208 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
209 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
210 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
211 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
212 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
213 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
214 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
215 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
216 fcn_idx = pos->second;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
217
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
218 if (! m_active_fcn)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
219 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
220
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
221 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
222
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
223 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
224
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
225 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
226
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
227 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
228 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
229 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
230 if (m_active_fcn)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
231 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
232 assert (m_call_tree);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
233 // FIXME: This assert statements doesn'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
234 // 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
235 //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
236
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
237 // Usually, if we are disabled this function is not even called. But the
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
238 // call disabling the profiler is an exception. So also check here
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
239 // 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
240 if (enabled ())
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
241 add_current_time ();
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
242
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
243 fcn_index_map::iterator pos = m_fcn_index.find (fcn);
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
244 // FIXME: This assert statements doesn'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
245 // 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
246 //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
247 m_active_fcn = m_active_fcn->exit (pos->second);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
248
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
249 // 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
250 // 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
251 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
252 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
253 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
254
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
255 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
256 profiler::reset (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
257 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
258 if (enabled ())
28919
7bc983bc2cbd maint: Prepend name of function to error() messages.
Rik <rik@octave.org>
parents: 28905
diff changeset
259 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
260
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
261 m_known_functions.clear ();
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
262 m_fcn_index.clear ();
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 if (m_call_tree)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
265 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
266 delete m_call_tree;
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 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
268 m_active_fcn = nullptr;
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
269 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
270
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 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
272 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
273
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
274 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
275 profiler::get_flat (void) const
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 retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
278
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
279 const octave_idx_type n = m_known_functions.size ();
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
280
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
281 flat_profile flat (n);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
282
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
283 if (m_call_tree)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
284 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
285 m_call_tree->build_flat (flat);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
286
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
287 Cell rv_names (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
288 Cell rv_times (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
289 Cell rv_calls (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
290 Cell rv_recursive (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
291 Cell rv_parents (n, 1);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
292 Cell rv_children (n, 1);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
293
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
294 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
295 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
296 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
297 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
298 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
299 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
300 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
301 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
302 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
303
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
304 octave_map m;
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 m.assign ("FunctionName", rv_names);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
307 m.assign ("TotalTime", rv_times);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
308 m.assign ("NumCalls", rv_calls);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
309 m.assign ("IsRecursive", rv_recursive);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
310 m.assign ("Parents", rv_parents);
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
311 m.assign ("Children", rv_children);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
312
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
313 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
314 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
315 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
316 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
317 static const char *fn[] =
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
318 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
319 "FunctionName",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
320 "TotalTime",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
321 "NumCalls",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
322 "IsRecursive",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
323 "Parents",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
324 "Children",
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23753
diff changeset
325 nullptr
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
326 };
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
327
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
328 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
329
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
330 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
331 }
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 return retval;
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 octave_value
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
337 profiler::get_hierarchical (void) const
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
338 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
339 octave_value retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
340
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
341 if (m_call_tree)
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
342 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
343 else
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
344 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
345 static const char *fn[] =
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
346 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
347 "Index",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
348 "SelfTime",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
349 "NumCalls",
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
350 "Children",
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23753
diff changeset
351 nullptr
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
352 };
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
353
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
354 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
355
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
356 retval = m;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
357 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
358
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
359 return retval;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
360 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
361
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
362 double
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
363 profiler::query_time (void) const
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 sys::time now;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
366
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
367 // 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
368 // 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
369 volatile double dnow = now.double_value ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
370
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
371 return dnow;
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
372 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
373
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
374 void
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
375 profiler::add_current_time (void)
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
376 {
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
377 if (m_active_fcn)
23753
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
378 {
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
379 const double t = query_time ();
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
380
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
381 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
382 }
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
383 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
384
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
385 // 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
386 DEFMETHOD (__profiler_enable__, interp, args, ,
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
387 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
388 @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
389 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
390 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
391 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
392 int nargin = args.length ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
393
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
394 if (nargin > 1)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
395 print_usage ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
396
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
397 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
398
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
399 if (nargin == 1)
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
400 {
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
401 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
402
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
403 std::string status = "off";
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
404 if (args(0).bool_value ())
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
405 status = "on";
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28919
diff changeset
406
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
407 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
408 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
409 }
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
410
24833
7c88cf242111 use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
411 return ovl (profiler.enabled ());
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
412 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
413
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
414 // 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
415 DEFMETHOD (__profiler_reset__, interp, args, ,
c3828bd031cd move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23752
diff changeset
416 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
417 @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
418 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
419 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
420 {
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
421 if (args.length () != 0)
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
422 print_usage ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
423
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
424 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
425
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
426 profiler.reset ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
427
20941
a4f5da7c5463 maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents: 20939
diff changeset
428 return ovl ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
429 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
430
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
431 // 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
432 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
433 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
434 @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
435 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
436 @end deftypefn */)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
437 {
23752
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
438 if (args.length () != 0)
6be1bf9455e3 fix argument checks for internal profiler functions
John W. Eaton <jwe@octave.org>
parents: 23751
diff changeset
439 print_usage ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
440
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
441 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
442
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
443 if (nargout > 1)
20898
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20892
diff changeset
444 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
445 else
8da80da1ac37 maint: Use ovl() more places in the code.
Rik <rik@octave.org>
parents: 20892
diff changeset
446 return ovl (profiler.get_flat ());
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
447 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
448
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
449 OCTAVE_NAMESPACE_END