Module pycallgraph
[hide private]
[frames] | no frames]

Module pycallgraph

source code

pycallgraph

U{http://pycallgraph.slowchop.com/}

Copyright Gerald Kaszuba 2007

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Version: 0.4.1

Author: Gerald Kaszuba

Classes [hide private]
  PyCallGraphException
Exception used for pycallgraph
  GlobbingFilter
Filter module names using a set of globs.
Functions [hide private]
 
colourize_node(calls, total_time) source code
 
colourize_edge(calls, total_time) source code
 
reset_settings() source code
 
reset_trace()
Resets all collected statistics.
source code
 
is_module_stdlib(file_name)
Returns True if the file_name is in the lib directory.
source code
 
start_trace(reset=True, filter_func=None, time_filter_func=None)
Begins a trace.
source code
 
stop_trace()
Stops the currently running trace, if any.
source code
 
tracer(frame, event, arg)
This is an internal function that is called every time a call is made during a trace.
source code
 
get_dot(stop=True)
Returns a string containing a DOT file.
source code
 
save_dot(filename)
Generates a DOT file and writes it into filename.
source code
 
make_graph(filename, format=None, tool=None, stop=None)
This has been changed to make_dot_graph.
source code
 
make_dot_graph(filename, format='png', tool='dot', stop=True)
Creates a graph using a Graphviz tool that supports the dot language.
source code
 
simple_memoize(callable_object)
Simple memoization for functions without keyword arguments.
source code
Variables [hide private]
  trace_filter = None
  time_filter = None
  settings = {'dont_exclude_anything': False, 'edge_colour': <fu...
  graph_attributes = {'graph': {'fontcolor': '0 0 0.5', 'fontnam...
  call_dict = {}
  call_stack = ['__main__']
  call_stack_timer = []
  func_count = {}
  func_count_max = 0
  func_time = {}
  func_time_max = 0

Imports: inspect, sys, os, re, tempfile, time, sysconfig


Function Details [hide private]

colourize_node(calls, total_time)

source code 

colourize_edge(calls, total_time)

source code 

reset_settings()

source code 

reset_trace()

source code 
Resets all collected statistics. This is run automatically by start_trace(reset=True) and when the module is loaded.

is_module_stdlib(file_name)

source code 
Returns True if the file_name is in the lib directory.

start_trace(reset=True, filter_func=None, time_filter_func=None)

source code 
Begins a trace. Setting reset to True will reset all previously recorded trace data. filter_func needs to point to a callable function that accepts the parameters (call_stack, module_name, class_name, func_name, full_name). Every call will be passed into this function and it is up to the function to decide if it should be included or not. Returning False means the call will be filtered out and not included in the call graph.

stop_trace()

source code 
Stops the currently running trace, if any.

tracer(frame, event, arg)

source code 
This is an internal function that is called every time a call is made during a trace. It keeps track of relationships between calls.

get_dot(stop=True)

source code 
Returns a string containing a DOT file. Setting stop to True will cause the trace to stop.

save_dot(filename)

source code 
Generates a DOT file and writes it into filename.

make_graph(filename, format=None, tool=None, stop=None)

source code 
This has been changed to make_dot_graph.

make_dot_graph(filename, format='png', tool='dot', stop=True)

source code 
Creates a graph using a Graphviz tool that supports the dot language. It will output into a file specified by filename with the format specified. Setting stop to True will stop the current trace.

simple_memoize(callable_object)

source code 

Simple memoization for functions without keyword arguments.

This is useful for mapping code objects to module in this context. inspect.getmodule() requires a number of system calls, which may slow down the tracing considerably. Caching the mapping from code objects (there is one code object for each function, regardless of how many simultaneous activations records there are).

In this context we can ignore keyword arguments, but a generic memoizer ought to take care of that as well.


Variables Details [hide private]

trace_filter

Value:
None

time_filter

Value:
None

settings

Value:
{'dont_exclude_anything': False,
 'edge_colour': <function colourize_edge at 0xb75c41c>,
 'include_stdlib': True,
 'node_attributes': {'color': '%(col)s',
                     'label': '%(func)s\\ncalls: %(hits)i\\ntotal time\
: %(total_time)f'},
 'node_colour': <function colourize_node at 0xb75c3ac>}

graph_attributes

Value:
{'graph': {'fontcolor': '0 0 0.5',
           'fontname': 'Verdana',
           'fontsize': 7,
           'label': 'Generated by Python Call Graph v0.4.1\\nhttp://py\
callgraph.slowchop.com'},
 'node': {'color': '.5 0 .9',
          'fontname': 'Verdana',
          'fontsize': 7,
...

call_dict

Value:
{}

call_stack

Value:
['__main__']

call_stack_timer

Value:
[]

func_count

Value:
{}

func_count_max

Value:
0

func_time

Value:
{}

func_time_max

Value:
0