annotate src/profiler.cc @ 16088:b29b10fbb744 stable release-3-6-4

Version 3.6.4 released. * configure.ac (AC_INIT): Version is now 3.6.4. (OCTAVE_RELEASE_DATE): Now 2013-02-21.
author John W. Eaton <jwe@octave.org>
date Thu, 21 Feb 2013 15:17:54 -0500
parents 06f706e92771
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
1 /*
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13272
diff changeset
3 Copyright (C) 2012 Daniel Kraft
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
4
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
5 This file is part of Octave.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
6
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
10 option) any later version.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
11
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
15 for more details.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
16
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
20
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
21 */
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
22
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
24 #include <config.h>
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
25 #endif
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
26
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
27 #include <iostream>
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
28
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
29 #include "defun.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
30 #include "oct-time.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
31 #include "ov-struct.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
32 #include "pager.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
33 #include "profiler.h"
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
34
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
35 profile_data_accumulator::enter::enter (profile_data_accumulator& a,
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
36 const std::string& f)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
37 : acc (a)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
38 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
39 if (acc.is_active ())
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
40 {
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
41 fcn = f;
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
42 acc.enter_function (fcn);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
43 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
44 else
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
45 fcn = "";
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
46 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
47
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
48 profile_data_accumulator::enter::~enter ()
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
49 {
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
50 if (fcn != "")
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
51 acc.exit_function (fcn);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
52 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
53
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
54 profile_data_accumulator::stats::stats ()
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
55 : time (0.0), calls (0), recursive (false),
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
56 parents (), children ()
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
57 {}
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
58
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
59 octave_value
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
60 profile_data_accumulator::stats::function_set_value (const function_set& list)
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
61 {
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
62 const octave_idx_type n = list.size ();
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
63
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
64 RowVector retval (n);
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
65 octave_idx_type i = 0;
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
66 for (function_set::const_iterator p = list.begin (); p != list.end (); ++p)
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
67 {
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
68 retval(i) = *p;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
69 ++i;
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
70 }
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
71 assert (i == n);
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
72
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
73 return retval;
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
74 }
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
75
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
76 profile_data_accumulator::tree_node::tree_node (tree_node* p, octave_idx_type f)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
77 : parent (p), fcn_id (f), children (), time (0.0), calls (0)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
78 {}
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
79
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
80 profile_data_accumulator::tree_node::~tree_node ()
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
81 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
82 for (child_map::iterator i = children.begin (); i != children.end (); ++i)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
83 delete i->second;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
84 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
85
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
86 profile_data_accumulator::tree_node*
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
87 profile_data_accumulator::tree_node::enter (octave_idx_type fcn)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
88 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
89 tree_node* retval;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
90
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
91 child_map::iterator pos = children.find (fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
92 if (pos == children.end ())
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
93 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
94 retval = new tree_node (this, fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
95 children[fcn] = retval;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
96 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
97 else
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
98 retval = pos->second;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
99
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
100 ++retval->calls;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
101 return retval;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
102 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
103
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
104 profile_data_accumulator::tree_node*
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
105 profile_data_accumulator::tree_node::exit (octave_idx_type fcn)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
106 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
107 assert (parent);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
108 assert (fcn_id == fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
109
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
110 return parent;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
111 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
112
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
113 void
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
114 profile_data_accumulator::tree_node::build_flat (flat_profile& data) const
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
115 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
116 // If this is not the top-level node, update profile entry for this function.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
117 if (fcn_id != 0)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
118 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
119 stats& entry = data[fcn_id - 1];
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13052
diff changeset
120
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
121 entry.time += time;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
122 entry.calls += calls;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
123
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
124 assert (parent);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
125 if (parent->fcn_id != 0)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
126 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
127 entry.parents.insert (parent->fcn_id);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
128 data[parent->fcn_id - 1].children.insert (fcn_id);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
129 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
130
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
131 if (!entry.recursive)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
132 for (const tree_node* i = parent; i; i = i->parent)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
133 if (i->fcn_id == fcn_id)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
134 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
135 entry.recursive = true;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
136 break;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
137 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
138 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
139
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
140 // Recurse on children.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
141 for (child_map::const_iterator i = children.begin ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
142 i != children.end (); ++i)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
143 i->second->build_flat (data);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
144 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
145
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
146 octave_value
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
147 profile_data_accumulator::tree_node::get_hierarchical (double* total) const
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
148 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
149 /* Note that we don't generate the entry just for this node, but rather
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
150 a struct-array with entries for all children. This way, the top-node
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
151 (for which we don't want a real entry) generates already the final
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
152 hierarchical profile data. */
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
153
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
154 const octave_idx_type n = children.size ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
155
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
156 Cell rv_indices (n, 1);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
157 Cell rv_times (n, 1);
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
158 Cell rv_totals (n, 1);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
159 Cell rv_calls (n, 1);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
160 Cell rv_children (n, 1);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
161
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
162 octave_idx_type i = 0;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
163 for (child_map::const_iterator p = children.begin ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
164 p != children.end (); ++p)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
165 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
166 const tree_node& entry = *p->second;
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
167 double child_total = entry.time;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
168
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
169 rv_indices(i) = octave_value (p->first);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
170 rv_times(i) = octave_value (entry.time);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
171 rv_calls(i) = octave_value (entry.calls);
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
172 rv_children(i) = entry.get_hierarchical (&child_total);
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
173 rv_totals(i) = octave_value (child_total);
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
174
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
175 if (total)
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
176 *total += child_total;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
177
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
178 ++i;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
179 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
180 assert (i == n);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
181
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
182 octave_map retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
183
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
184 retval.assign ("Index", rv_indices);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
185 retval.assign ("SelfTime", rv_times);
13188
6d57e53b21ea Add field for total time to hierarchical profile.
Daniel Kraft <d@domob.eu>
parents: 13141
diff changeset
186 retval.assign ("TotalTime", rv_totals);
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
187 retval.assign ("NumCalls", rv_calls);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
188 retval.assign ("Children", rv_children);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
189
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
190 return retval;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
191 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
192
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
193 profile_data_accumulator::profile_data_accumulator ()
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
194 : known_functions (), fcn_index (),
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
195 enabled (false), call_tree (NULL), last_time (-1.0)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
196 {}
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
197
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
198 profile_data_accumulator::~profile_data_accumulator ()
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
199 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
200 if (call_tree)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
201 delete call_tree;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
202 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
203
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
204 void
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
205 profile_data_accumulator::set_active (bool value)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
206 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
207 if (value)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
208 {
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
209 // Create a call-tree top-node if there isn't yet one.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
210 if (!call_tree)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
211 call_tree = new tree_node (NULL, 0);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
212
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
213 // Let the top-node be the active one. This ensures we have a clean
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
214 // fresh start collecting times.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
215 active_fcn = call_tree;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
216 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
217 else
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
218 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
219 // Make sure we start with fresh timing if we're re-enabled later.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
220 last_time = -1.0;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
221 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
222
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
223 enabled = value;
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
224 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
225
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
226 void
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
227 profile_data_accumulator::enter_function (const std::string& fcn)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
228 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
229 // The enter class will check and only call us if the profiler is active.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
230 assert (is_active ());
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
231 assert (call_tree);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
232
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
233 // If there is already an active function, add to its time before
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
234 // pushing the new one.
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
235 if (active_fcn != call_tree)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
236 add_current_time ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
237
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
238 // Map the function's name to its index.
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
239 octave_idx_type fcn_idx;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
240 fcn_index_map::iterator pos = fcn_index.find (fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
241 if (pos == fcn_index.end ())
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
242 {
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
243 known_functions.push_back (fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
244 fcn_idx = known_functions.size ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
245 fcn_index[fcn] = fcn_idx;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
246 }
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
247 else
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
248 fcn_idx = pos->second;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
249
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
250 active_fcn = active_fcn->enter (fcn_idx);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
251 last_time = query_time ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
252 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
253
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
254 void
12920
5d18231eee00 Extend profiling support to operators.
Daniel Kraft <d@domob.eu>
parents: 12870
diff changeset
255 profile_data_accumulator::exit_function (const std::string& fcn)
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
256 {
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
257 assert (call_tree);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
258 assert (active_fcn != call_tree);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
259
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
260 // Usually, if we are disabled this function is not even called. But the
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
261 // call disabling the profiler is an exception. So also check here
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
262 // and only record the time if enabled.
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
263 if (is_active ())
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
264 add_current_time ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
265
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
266 fcn_index_map::iterator pos = fcn_index.find (fcn);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
267 assert (pos != fcn_index.end ());
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
268 active_fcn = active_fcn->exit (pos->second);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
269
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
270 // If this was an "inner call", we resume executing the parent function
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
271 // up the stack. So note the start-time for this!
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
272 last_time = query_time ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
273 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
274
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
275 void
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
276 profile_data_accumulator::reset (void)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
277 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
278 if (is_active ())
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
279 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
280 error ("Can't reset active profiler.");
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
281 return;
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
282 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
283
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
284 known_functions.clear ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
285 fcn_index.clear ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
286
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
287 if (call_tree)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
288 {
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
289 delete call_tree;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
290 call_tree = NULL;
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
291 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
292
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
293 last_time = -1.0;
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
294 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
295
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
296 octave_value
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
297 profile_data_accumulator::get_flat (void) const
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
298 {
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
299 octave_value retval;
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
300
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
301 const octave_idx_type n = known_functions.size ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
302
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
303 flat_profile flat (n);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
304
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
305 if (call_tree)
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
306 {
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
307 call_tree->build_flat (flat);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
308
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
309 Cell rv_names (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
310 Cell rv_times (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
311 Cell rv_calls (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
312 Cell rv_recursive (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
313 Cell rv_parents (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
314 Cell rv_children (n, 1);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
315
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
316 for (octave_idx_type i = 0; i != n; ++i)
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
317 {
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
318 rv_names(i) = octave_value (known_functions[i]);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
319 rv_times(i) = octave_value (flat[i].time);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
320 rv_calls(i) = octave_value (flat[i].calls);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
321 rv_recursive(i) = octave_value (flat[i].recursive);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
322 rv_parents(i) = stats::function_set_value (flat[i].parents);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
323 rv_children(i) = stats::function_set_value (flat[i].children);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
324 }
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
325
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
326 octave_map m;
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
327
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
328 m.assign ("FunctionName", rv_names);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
329 m.assign ("TotalTime", rv_times);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
330 m.assign ("NumCalls", rv_calls);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
331 m.assign ("IsRecursive", rv_recursive);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
332 m.assign ("Parents", rv_parents);
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
333 m.assign ("Children", rv_children);
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
334
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
335 retval = m;
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
336 }
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
337 else
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
338 {
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
339 static const char *fn[] =
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
340 {
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
341 "FunctionName",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
342 "TotalTime",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
343 "NumCalls",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
344 "IsRecursive",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
345 "Parents",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
346 "Children",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
347 0
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
348 };
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
349
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
350 static octave_map m (dim_vector (0, 1), string_vector (fn));
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
351
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
352 retval = m;
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
353 }
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
354
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
355 return retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
356 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
357
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
358 octave_value
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
359 profile_data_accumulator::get_hierarchical (void) const
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
360 {
13052
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
361 octave_value retval;
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
362
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
363 if (call_tree)
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
364 retval = call_tree->get_hierarchical ();
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
365 else
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
366 {
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
367 static const char *fn[] =
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
368 {
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
369 "Index",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
370 "SelfTime",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
371 "NumCalls",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
372 "Children",
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
373 0
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
374 };
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
375
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
376 static octave_map m (dim_vector (0, 1), string_vector (fn));
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
377
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
378 retval = m;
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
379 }
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
380
43dcb0093ebd allow profile ('info') to work if no profiling data is available
John W. Eaton <jwe@octave.org>
parents: 12955
diff changeset
381 return retval;
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
382 }
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
383
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
384 double
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
385 profile_data_accumulator::query_time (void) const
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
386 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
387 octave_time now;
14345
06f706e92771 avoid profiler test failure on more systems
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
388
06f706e92771 avoid profiler test failure on more systems
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
389 // FIXME -- is this volatile declaration really needed?
06f706e92771 avoid profiler test failure on more systems
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
390 // See bug #34210 for additional details.
06f706e92771 avoid profiler test failure on more systems
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
391 volatile double dnow = now.double_value ();
06f706e92771 avoid profiler test failure on more systems
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
392
13269
b1882a8217ab avoid apparent compiler optimization problem on Cygwin and MinGW systems (bug #34210)
John W. Eaton <jwe@octave.org>
parents: 13188
diff changeset
393 return dnow;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
394 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
395
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
396 void
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
397 profile_data_accumulator::add_current_time (void)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
398 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
399 const double t = query_time ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
400 assert (last_time >= 0.0 && last_time <= t);
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
401
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
402 assert (call_tree && active_fcn != call_tree);
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
403 active_fcn->add_time (t - last_time);
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
404 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
405
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
406 profile_data_accumulator profiler;
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
407
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
408 // Enable or disable the profiler data collection.
12955
05941540287c Style fixes on profiler internal functions
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12954
diff changeset
409 DEFUN (__profiler_enable__, args, ,
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
410 "-*- texinfo -*-\n\
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
411 @deftypefn {Function File} __profiler_enable ()\n\
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
412 Undocumented internal function.\n\
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
413 @end deftypefn")
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
414 {
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
415 octave_value_list retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
416
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
417 const int nargin = args.length ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
418 if (nargin > 0)
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
419 {
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
420 if (nargin > 1)
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
421 {
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
422 print_usage ();
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
423 return retval;
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
424 }
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
425
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
426 profiler.set_active (args(0).bool_value ());
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
427 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
428
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
429 retval(0) = profiler.is_active ();
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
430
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
431 return retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
432 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
433
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
434 // Clear all collected profiling data.
12955
05941540287c Style fixes on profiler internal functions
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12954
diff changeset
435 DEFUN (__profiler_reset__, args, ,
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
436 "-*- texinfo -*-\n\
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
437 @deftypefn {Function File} __profiler_reset ()\n\
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
438 Undocumented internal function.\n\
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
439 @end deftypefn")
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
440 {
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
441 octave_value_list retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
442 const int nargin = args.length ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
443
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
444 if (nargin > 0)
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
445 warning ("profiler_reset: ignoring extra arguments");
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
446
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
447 profiler.reset ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
448
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
449 return retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
450 }
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
451
12870
39d813616c8f Restore the docstrings for internal profiler functions as C++ comments
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12869
diff changeset
452 // Query the timings collected by the profiler.
12955
05941540287c Style fixes on profiler internal functions
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12954
diff changeset
453 DEFUN (__profiler_data__, args, nargout,
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
454 "-*- texinfo -*-\n\
12869
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
455 @deftypefn {Function File} __profiler_data ()\n\
de9a9719e594 Extend data collection in profiler and add user-interface profile function.
Daniel Kraft <d@domob.eu>
parents: 12784
diff changeset
456 Undocumented internal function.\n\
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
457 @end deftypefn")
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
458 {
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
459 octave_value_list retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
460 const int nargin = args.length ();
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
461
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
462 if (nargin > 0)
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
463 warning ("profiler_data: ignoring extra arguments");
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
464
12954
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
465 retval(0) = profiler.get_flat ();
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
466 if (nargout > 1)
a451ae847adb Collect hierarchical data profile.
Daniel Kraft <d@domob.eu>
parents: 12920
diff changeset
467 retval(1) = profiler.get_hierarchical ();
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
468
12784
c499d54796d6 Minor stylistic fixes to profiler code
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12783
diff changeset
469 return retval;
12783
ad9263d965dc First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
diff changeset
470 }