コード例 #1
0
def main():
    gephi = GephiOutput()
    gephi.output_file = 'large.gdf'

    with PyCallGraph(output=gephi):
        from urllib3 import urlopen
        from xml.dom.minidom import parseString
        parseString(urlopen('http://w3.org/').read())
コード例 #2
0
def test_simple(graphviz):
    with PyCallGraph(output=graphviz):
        one_nop()
    dot = open(graphviz.output_file).read()
    os.unlink(graphviz.output_file)

    assert 'digraph G' in dot
    assert 'subgraph cluster_test' in dot
コード例 #3
0
def main():
    graphviz = GraphvizOutput()
    graphviz.output_file = 'large.png'
    config = Config(include_stdlib=True)

    with PyCallGraph(output=graphviz, config=config):
        from urllib3 import urlopen
        from xml.dom.minidom import parseString
        parseString(urlopen('http://w3.org/').read())
コード例 #4
0
def main():
    graphviz = GraphvizOutput()
    graphviz.output_file = 'basic.png'

    with PyCallGraph(output=graphviz):
        person = Person()
        for a in xrange(10):
            person.add_banana(Banana())
        person.eat_bananas()
コード例 #5
0
def test_simple(gephi):
    with PyCallGraph(output=gephi):
        one_nop()
    generated = open(gephi.output_file).read()
    os.unlink(gephi.output_file)

    assert 'nodedef> name VARCHAR' in generated
    assert 'edgedef> node1 VARCHAR, node2 VARCHAR' in generated
    assert 'test.calls.one_nop,1,true,true' in generated
    assert 'test.calls.one_nop,test.calls.nop,1,true,true' in generated
コード例 #6
0
def main():
    graphviz = GraphvizOutput()
    graphviz.output_file = 'recursive.png'

    with PyCallGraph(output=graphviz):
        try:
            for a in xrange(1, 10):
                factorial(a)
        except:
            for a in range(1, 10):
                factorial(a)
コード例 #7
0
def main():
    import_list = (
        'pickle',
        'htmllib',
        'urllib2',
    )
    graphviz = GraphvizOutput()
    config = Config(include_stdlib=True)

    for module in import_list:
        graphviz.output_file = 'import-{}.png'.format(module)
        with PyCallGraph(output=graphviz, config=config):
            __import__(module)
コード例 #8
0
def main():
    gephi = GephiOutput()
    gephi.output_file = 'basic.gdf'

    with PyCallGraph(output=gephi):
        person = Person()
        try:
            for a in xrange(10):
                person.add_banana(Banana())
        except:
            for a in range(10):
                person.add_banana(Banana())
        person.eat_bananas()
コード例 #9
0
def run(name, trace_filter=None, config=None, comment=None):
    if not config:
        config = Config()

    if trace_filter:
        config.trace_filter = trace_filter

    graphviz = GraphvizOutput()
    graphviz.output_file = 'filter-{}.png'.format(name)
    if comment:
        graphviz.graph_attributes['graph']['label'] = comment

    with PyCallGraph(config=config, output=graphviz):
        banana = Banana()
        banana.eat()
コード例 #10
0
def run(name, trace_grouper=None, config=None, comment=None):
    if not config:
        config = Config()

    config.trace_filter = GlobbingFilter()

    if trace_grouper is not None:
        config.trace_grouper = trace_grouper

    graphviz = GraphvizOutput()
    graphviz.output_file = 'grouper-{}.png'.format(name)
    if comment:
        graphviz.graph_attributes['graph']['label'] = comment

    with PyCallGraph(config=config, output=graphviz):
        example_with_submodules.main()
コード例 #11
0
def main():
    graphviz = GraphvizOutput()
    pycallgraph = PyCallGraph(output=graphviz,
                              config=Config(include_stdlib=True))

    pycallgraph.start()
    pycallgraph.stop()

    # Set the edge colour to black for all examples
    graphviz.edge_color_func = lambda e: Color(0, 0, 0)

    # Default node colouring
    graphviz.output_file = 'colours-default.png'
    graphviz.done()

    def run(func, output_file):
        graphviz.node_color_func = func
        graphviz.output_file = output_file
        graphviz.done()

    run(rainbow, 'colors-rainbow.png')
    run(greyscale, 'colors-greyscale.png')
    run(orange_green, 'colors-orange-green.png')
    run(rand, 'colors-random.png')
コード例 #12
0
def pycg():
    return PyCallGraph()