Mercurial > octave-libgccjit
annotate libinterp/corefcn/profiler.cc @ 17787:175b392e91fe
Use GNU style coding conventions for code in libinterp/
* libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h,
libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc,
libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc,
libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc,
libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc,
libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc,
libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h,
libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h,
libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc,
libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc,
libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc,
libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc,
libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h,
libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc,
libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc,
libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc,
libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc,
libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h,
libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h,
libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h,
libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h,
libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h,
libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc,
libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc,
libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc,
libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc,
libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc,
libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc,
libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc,
libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc,
libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc,
libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc,
libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc,
libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc,
libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/ops.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h,
libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h,
libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h,
libinterp/parse-tree/token.h, libinterp/version.cc:
Use GNU style coding conventions for code in libinterp/
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Oct 2013 19:51:46 -0700 |
parents | d63878346099 |
children | 8c33abdd2f9a |
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 |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16892
diff
changeset
|
3 Copyright (C) 2012-2013 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[] = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
340 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 "FunctionName", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
342 "TotalTime", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 "NumCalls", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 "IsRecursive", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
345 "Parents", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
346 "Children", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
347 0 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
348 }; |
13052
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[] = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
368 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
369 "Index", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
370 "SelfTime", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
371 "NumCalls", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
372 "Children", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
373 0 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
374 }; |
13052
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 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
389 // FIXME: is this volatile declaration really needed? |
14345
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, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
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, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
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, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
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 } |