Mercurial > octave
annotate libinterp/parse-tree/profiler.cc @ 30888:32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
For new users of Octave it is best to show explicit calling forms
in the documentation and to show a return argument when it exists.
* __ftp__.cc, __magick_read__.cc, __pchip_deriv__.cc, bitfcns.cc, bsxfun.cc,
call-stack.cc, cellfun.cc, chol.cc, conv2.cc, data.cc, debug.cc, defaults.cc,
det.cc, dirfns.cc, display.cc, dot.cc, error.cc, event-manager.cc, fft.cc,
fft2.cc, fftn.cc, file-io.cc, getgrent.cc, getpwent.cc, getrusage.cc,
graphics.cc, hash.cc, help.cc, input.cc, interpreter.cc, kron.cc, load-path.cc,
mappers.cc, max.cc, nproc.cc, oct-hist.cc, pager.cc, pinv.cc, psi.cc, rand.cc,
settings.cc, sighandlers.cc, stream-euler.cc, strfns.cc, symtab.cc,
syscalls.cc, sysdep.cc, time.cc, toplev.cc, utils.cc, variables.cc,
__fltk_uigetfile__.cc, audiodevinfo.cc, audioread.cc, fftw.cc, ov-bool-mat.cc,
ov-cell.cc, ov-class.cc, ov-classdef.cc, ov-fcn-handle.cc, ov-java.cc,
ov-struct.cc, ov-typeinfo.cc, ov-usr-fcn.cc, ov.cc, octave.cc, profiler.cc:
Add return arguments to @deftypefn macros where they were missing.
Attempt to use standard naming convention for return variables.
Occasionally improved the docstring itself by re-wording or adding code
examples.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 Apr 2022 10:31:48 -0700 |
parents | 08b08b7f05b2 |
children | e88a07dec498 |
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 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
3 // Copyright (C) 2012-2022 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 return retval; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
56 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
57 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
58 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
|
59 : 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
|
60 { } |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
61 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
62 profiler::tree_node::~tree_node () |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
63 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
64 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
|
65 delete idx_tnode.second; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
66 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
67 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
68 profiler::tree_node* |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
69 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
|
70 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
71 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
|
72 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
73 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
|
74 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
|
75 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
76 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
|
77 m_children[fcn] = retval; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
78 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
79 else |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
80 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
|
81 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
82 ++retval->m_calls; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
83 return retval; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
84 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
85 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
86 profiler::tree_node* |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
87 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
|
88 { |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
89 // FIXME: These panic_unless statements don't make sense if profile() is |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
90 // called from within a function hierarchy to begin with. See bug #39587. |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
91 // panic_unless (m_parent); |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
92 // panic_unless (m_fcn_id == fcn); |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
93 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
94 return m_parent; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
95 } |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
96 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
97 void |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
98 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
|
99 { |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
100 // 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
|
101 // 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
|
102 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
|
103 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
104 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
|
105 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 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
|
107 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
|
108 |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
109 panic_unless (m_parent); |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 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
|
111 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
112 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
|
113 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
|
114 } |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
115 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 if (! entry.m_recursive) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 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
|
118 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
|
119 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 entry.m_recursive = true; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
121 break; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
122 } |
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 // Recurse on children. |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 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
|
127 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
|
128 } |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
129 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
130 octave_value |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
131 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
|
132 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
133 // 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
|
134 // 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
|
135 // 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
|
136 // the final hierarchical profile data. |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
137 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 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
|
139 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
140 Cell rv_indices (n, 1); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
141 Cell rv_times (n, 1); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
142 Cell rv_totals (n, 1); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
143 Cell rv_calls (n, 1); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
144 Cell rv_children (n, 1); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
145 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
146 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
|
147 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
|
148 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
149 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
|
150 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
|
151 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 rv_totals(i) = octave_value (child_total); |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
157 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
158 if (total) |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
159 *total += child_total; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
160 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
161 ++i; |
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 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
164 octave_map retval; |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
165 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
166 retval.assign ("Index", rv_indices); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
167 retval.assign ("SelfTime", rv_times); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
168 retval.assign ("TotalTime", rv_totals); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
169 retval.assign ("NumCalls", rv_calls); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
170 retval.assign ("Children", rv_children); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
171 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
172 return retval; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
173 } |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
174 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
175 profiler::profiler (void) |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 : 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
|
177 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
|
178 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
|
179 { } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
180 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
181 profiler::~profiler (void) |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
182 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
183 delete m_call_tree; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
184 } |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13052
diff
changeset
|
185 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
186 void |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
187 profiler::set_active (bool value) |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
188 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
189 m_enabled = value; |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
190 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
191 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
192 void |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
193 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
|
194 { |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
195 // The enter class will check and only call us if the profiler is active. |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
196 panic_unless (enabled ()); |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
197 panic_unless (m_call_tree); |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
198 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
199 // 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
|
200 // 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
|
201 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
|
202 add_current_time (); |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
203 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
204 // 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
|
205 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
|
206 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
|
207 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
|
208 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 } |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
213 else |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
214 fcn_idx = pos->second; |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
215 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
216 if (! m_active_fcn) |
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
217 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
|
218 |
24833
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_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
|
220 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
221 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
|
222 |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
223 } |
12954
a451ae847adb
Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
224 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
225 void |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
226 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
|
227 { |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
228 if (m_active_fcn) |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
229 { |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
230 panic_unless (m_call_tree); |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
231 // FIXME: This panic_unless statements doesn't make sense if profile() |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
232 // is called from within a function hierarchy to begin with. |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
233 // See bug #39587. |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
234 // panic_unless (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
|
235 |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
236 // 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
|
237 // 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
|
238 // 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
|
239 if (enabled ()) |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
240 add_current_time (); |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23752
diff
changeset
|
241 |
24833
7c88cf242111
use m_ prefix for data members in more classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
242 fcn_index_map::iterator pos = m_fcn_index.find (fcn); |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
243 // FIXME: This panic_unless statements doesn't make sense if profile() |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
244 // is called from within a function hierarchy to begin with. |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
245 // See bug #39587. |
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30565
diff
changeset
|
246 // panic_unless (pos != m_fcn_index.end ()); |
24833
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 -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30723
diff
changeset
|
388 @deftypefn {} {@var{state} =} __profiler_enable__ () |
21966
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 -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30723
diff
changeset
|
434 @deftypefn {} {@var{data} =} __profiler_data__ () |
21966
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 |