Mercurial > octave
diff src/profiler.h @ 12869:de9a9719e594
Extend data collection in profiler and add user-interface profile function.
* scripts/general/module.mk: Add profile.m.
* scripts/general/profile.m: New file.
* src/profiler.h (stats): New utility class.
(data): Field to replace old times, can now hold more info.
* src/profiler.cc (stats): Implementation of routines.
(profile_data_accumulator): Changes necessary because call_stack was
changed to be a std::vector now and for the new statistics map.
(profile_data_accumulator::get_data): Extended to produce much more
sophisticated output.
(profile_data_accumulator::enter_function): Collect some more data
than the timing.
author | Daniel Kraft <d@domob.eu> |
---|---|
date | Thu, 14 Jul 2011 22:16:24 +0200 |
parents | ad9263d965dc |
children | 5d18231eee00 |
line wrap: on
line diff
--- a/src/profiler.h Fri Jul 22 13:15:00 2011 -0700 +++ b/src/profiler.h Thu Jul 14 22:16:24 2011 +0200 @@ -23,11 +23,12 @@ #if !defined (octave_profiler_h) #define octave_profiler_h 1 -#include <stack> #include <map> +#include <set> +#include <vector> class octave_function; -class Cell; +class octave_value; class OCTAVE_API @@ -68,16 +69,43 @@ void reset (void); - Cell get_data (void) const; + octave_value get_data (void) const; private: + typedef std::set<std::string> function_set; + typedef std::map<std::string, octave_idx_type> fcn_index_map; + + // Store some statistics data collected for a function. + class stats + { + private: + + double time; + unsigned calls; + + bool recursive; + + function_set parents; + function_set children; + + public: + + stats (); + + static octave_value + function_set_value (const function_set&, const fcn_index_map&); + + friend class profile_data_accumulator; + }; + bool enabled; - std::stack<const octave_function*> call_stack; + typedef std::vector<const octave_function*> call_stack_type; + call_stack_type call_stack; - typedef std::map<std::string, double> timing_map; - timing_map times; + typedef std::map<std::string, stats> stats_map; + stats_map data; // Store last timestamp we had, when the currently active function was called. double last_time;